Skip to main content

Project 1: Interactive led

How does it work?

Whenever a press the button the led is switched on. 
After 2 seconds the led is switched off.

Things you need:

  • a Breadboard
  • a led
  • a button
  • 2 resistors (220Ohms)
  • jumper wires.

Connect it up

Now, first make sure that your Arduino is powered off (unplug the USB cable or the external battery).
Then connect everything up like this:

The led

Make sure that your LED is connected the right way with the longer leg connected to Digital pin 8.
The long leg is the Anode of the LED and always must go to the +5V supply (in this cased coming out of Digital pin 8).
And the short leg is the Cathode and is connected to a resistor (to limit the current that goes through the led and then to Gnd (Ground).

The button

Normally the button is not pressed and therefore the circuit is open and 0V(LOW) will be supplied to pin3.
When the button is pressed, the circuit is closed and 5V(HIGH) will be supplied to pin3.

Arduino board will read the PIN3 and if it is HIGH Arduino will send 5V to pin8 so the led will be switched on. 
After a while (a delay we introduce in the code) the led will be switched off again until someone presses it again.

The code
We can use Bitbloq free software to easily code the program using blocks.
By adding the different components, the needed blocks will become available.

The program using blocks:



BitBloq Application will translate those blocks into the Arduino code. See how it looks like:

You can see that in the code we are sending the value read in pin3 (variable press) through the serial port to the computer, so we can see the value on the Serial Monitor (view menu)

Comments

Popular posts from this blog

Build a greenhouse with Arduino

What is a greenhouse?  How do you think technology can improve greenhouses? Do you think that a greenhouse can be controlled by a computer to optimise the conditions for plant growth? In a greenhouse, plants requiring regulated climatic conditions are grown. Temperature, humidity and light are some important measurements to take when cultivating a specific crop? Our challenge: Lets build a greenhouse and the control system to set and keep the optimal climate conditions in terms of temperature and humidity and cultivate some tropical crops. Optimal climate conditions temperature: between 25-30ºC humidity : 50-60% If the temperature and humidity sensors register a value out of these ranges, the Arduino board should trigger an alarm (the led will light) to let us know that some actions are needed (we might need to activate the heating or watering system) After restoring the temperature and humidity values, the led should be turned off. Build

Some basics of ARDUINO