Wednesday, 24 January 2018

Arduino IoT Tutorial 1 – Digital Input/Output

Components Required:

1. Arduino Uno – Buy2. Linux PC/Windows PC (Tested with Windows 10, Ubuntu 14.04 LTS)3. USB cable A to B –  Buy4. Breadboard5. 5 mm LED – Buy6. 220 Ohms Resistor (color code – Red, Red, Brown)7. Momentary button or Switch8. 10K Ohms Resistor (color code – Brown, Black, Orange)9Jumper Wires

Procedure:

1. Connect Arduino Uno to PC via the USB cable.
2. Write the following sketches in the Arduino IDE, and upload them one by one.

LEDControl.ino

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(2000);              // wait for a second
}

ButtonLEDControl.ino

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

Hardware Connections:

1. LED to Arduino Uno
2. Button to Arduino Uno



No comments:

Post a Comment

SMART BLIND STICK The smart blind stick is the project made to help the blind people who is suffering when walking.It just uses to de...