Arduino

Arduino –

First Use of Sensor and Actuator:

 

Interactive Devices

Arduino is used to build certain devices with very simple pattern known as interact devices.These interactive devices are basically electronic circuits which can sense environment by using sensors(electronic components that convert real-world measurements into electrical signals). The device processes the information it gets from the sensors with behavior that’s described in the software. The device will then be able to interact with the world by using actuators, electronic components that can convert an electric signal into a physical action.

  • Sensors and Actuators
  • Circuit Connections
  • Push Buttons and Arduino Instruction
  • Code for turning on LED with a Switch
  • Code for staying LED on even after releasing the switch
  • In next tutorial

These are electronic components that allow a piece of electronics to interact with the world.

As a simple computer a micro-controller process only electric signals. Once the sensors have been read, the device has the information needed to decide how to react. The decision-making process is handled by the micro-controller, and the reaction is performed by actuators which can be a light or an electric motor. In the following sections, you will learn how to read sensors of different types and control different kinds of actuators.

we will be working on how to design interactive lamps, using Arduino as a way to learn the basics of how interactive devices are built. Remember, though, that Arduino doesn’t really understand, or care, what you connect to the output pins. Arduino just turns the pin HIGH or LOW, which could be controlling a light, or an electric motor, or your car engine.

Using a Push button to Control the LED Blinking an LED was easy, but I don’t think you would stay sane if your desk lamp were to continuously blink while you were trying to read a book. Therefore, you need to learn how to control it. In the previous example, the LED was your actuator, and the Arduino was controlling it. What’s missing to complete the picture is a sensor. In this case, we’re going to use the simplest form of sensor available: a push button switch.

 If you were to take apart a push-button, you would see that it is a very simple device: two bits of metal kept apart by a spring, and a plastic cap that when pressed brings the two bits of metal into contact. When the bits of metal are apart, there is no circulation of current in the push-button (a bit like when a water valve is closed); when you press it, you make a connection. All switches are basically just this: two (or more) pieces of metal that can be brought into contact with each other, allowing electricity to flow from one to the other, or separated, preventing the flow of electricity.

To monitor the state of a switch, there’s a new Arduino instruction that you’re going to learn: the digitalRead() function. digitalRead() checks to see whether there is any voltage applied to the pin that you specify between parentheses, and returns a value of HIGH or LOW, depending on its findings. The other instructions that you’ve used so far haven’t returned any information—they just executed what we asked them to do. But that kind of function is a bit limited, because it will force you to stick with very predictable sequences of instructions, with no input from the outside world. With digitalRead(), you can “ask a question” of Arduino and receive an answer that can be stored in memory somewhere and used to make decisions immediately or later.

It’s important to realize that the switch is not connected directly to the LED. Your Arduino sketch inspects the switch, and then makes a decision as to whether to turn the LED on or off. The connection between the switch and the LED is really happening in your sketch.

 

 

// Turn on LED while the button is pressed

const int LED = 13;                       // the pin for the LED

const int BUTTON = 6;              // the input pin where the pushbutton is connected

int val = 0;                                // val will be used to store the state of the input pin

void setup()

{

pinMode(LED, OUTPUT);            // tell Arduino LED is an output

pinMode(BUTTON, INPUT);       // and BUTTON is an input }

void loop()

{

val = digitalRead(BUTTON);   // read input value and store it

// check whether the input is HIGH (button pressed)

if (val == HIGH)

{

digitalWrite(LED, HIGH);              // turn LED ON

}

Else

1 Comment

  • such a nice topic. please share me how can i connect aurdino board with LCD.

    vivan sharma July 18, 2017

Leave a comment

Your email address will not be published.