2. BLINKING OF LED USING
ARDUINO.
REQUIREMENTS:
• 1 Arduino UNO Board, Wire
Interfaces, LEDs
• THEORY:
In this we have perform a practical
of blinking of LED using Arduino
using the following steps-
3. • Step1: Connect the LED with 13
and ground off arduino.
• Step2: Connect the arduino with
the system.
• Step3: Open arduino software and
Blinking Code.
• Step4: Verify and upload the
program in the arduino and get the
output.
4. Checking the Voltage Variation of
Arduino UNO in IoT Platform
Ubidots
REQUIREMENTS:
• Arduino UNO Board, Ethernet
Shield, Interfacing Wires.
THEORY:
• In this we check the voltage
variation of arduino on IoT
Platform (ubidots.com)
21. Code-
#include <ThingSpeak.h>
/*
WriteVoltage
Reads an analog voltage from pin 0, and writes it to a channel on
ThingSpeak every 20 seconds.
ThingSpeak ( https://www.thingspeak.com ) is a free IoT service for
prototyping
systems that collect, analyze, and react to their environments.
Copyright 2015, The MathWorks, Inc.
Documentation for the ThingSpeak Communication Library for Arduino is in
the extras/documentation folder where the library was installed.
See the accompaning licence file for licensing information.
*/
22. #ifdef SPARK
#include "ThingSpeak/ThingSpeak.h"
#else
#include "ThingSpeak.h"
#endif
///
*************************************************************************************************
**********
// This example selects the correct library to use based on the board selected under the
Tools menu in the IDE.
// Yun, Wired Ethernet shield, wi-fi shield, esp8266, and Spark are all supported.
// With Uno and Mega, the default is that you're using a wired ethernet shield
(http://www.arduino.cc/en/Main/ArduinoEthernetShield)
// If you're using a wi-fi shield (http://www.arduino.cc/en/Main/ArduinoWiFiShield),
uncomment the line below
//
*************************************************************************************************
**********
//#define USE_WIFI_SHIELD
#ifdef ARDUINO_ARCH_AVR
#ifdef ARDUINO_AVR_YUN
#include "YunClient.h"
23. YunClient client;
#else
#ifdef USE_WIFI_SHIELD
#include <SPI.h>
// ESP8266 USERS -- YOU MUST COMMENT OUT THE LINE BELOW. There's a
bug in the Arduino IDE that causes it to not respect #ifdef when it comes to #includes
// If you get "multiple definition of `WiFi'" -- comment out the line below.
#include <WiFi.h>
char ssid[] = "<YOURNETWORK>"; // your network SSID (name)
char pass[] = "<YOURPASSWORD>"; // your network password
int status = WL_IDLE_STATUS;
WiFiClient client;
#else
// Use wired ethernet shield
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
EthernetClient client;
#endif
#endif
// On Arduino: 0 - 1023 maps to 0 - 5 volts
#define VOLTAGE_MAX 5.0
24. #define VOLTAGE_MAXCOUNTS 1023.0
#endif
#ifdef ARDUINO_ARCH_ESP8266
#include <ESP8266WiFi.h>
char ssid[] = "<YOURNETWORK>"; // your network SSID (name)
char pass[] = "<YOURPASSWORD>"; // your network password
int status = WL_IDLE_STATUS;
WiFiClient client;
// On ESP8266: 0 - 1023 maps to 0 - 1 volts
#define VOLTAGE_MAX 1.0
#define VOLTAGE_MAXCOUNTS 1023.0
#endif
#ifdef SPARK
TCPClient client;
// On Particle: 0 - 4095 maps to 0 - 3.3 volts
#define VOLTAGE_MAX 3.3
#define VOLTAGE_MAXCOUNTS 4095.0
#endif
/*
*****************************************************************************************
25. **** Visit https://www.thingspeak.com to sign up for a free account and create
**** a channel. The video tutorial http://community.thingspeak.com/tutorials/thingspeak-
channels/
**** has more information. You need to change this to your channel, and your write API
key
**** IF YOU SHARE YOUR CODE WITH OTHERS, MAKE SURE YOU REMOVE YOUR
WRITE API KEY!!
*****************************************************************************************/
unsigned long myChannelNumber = 124278;
const char * myWriteAPIKey = "04377LL7I54LVCNZ";
void setup() {
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ESP8266)
#ifdef ARDUINO_AVR_YUN
Bridge.begin();
#else
#if defined(USE_WIFI_SHIELD) || defined(ARDUINO_ARCH_ESP8266)
WiFi.begin(ssid, pass);
#else
Ethernet.begin(mac);
#endif
26. #endif
#endif
ThingSpeak.begin(client);
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading
// On Arduino: 0 - 1023 maps to 0 - 5 volts
// On ESP8266: 0 - 1023 maps to 0 - 1 volts
// On Particle: 0 - 4095 maps to 0 - 3.3 volts
float voltage = sensorValue * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);
// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8
different
// pieces of information in a channel. Here, we write to field 1.
ThingSpeak.writeField(myChannelNumber, 1, voltage, myWriteAPIKey);
delay(20000); // ThingSpeak will only accept updates every 15 seconds.
}
27. Glowing Of LED Using I/R
Sensor.
REQUIREMENTS:
Arduino UNO Board, Breadboard, LED, I/R Sensor,
Wire Interfaces.
THEORY:
Here we glow the LED using I/R sensor. In this when
our hand come closer towards the I/R sensor the
LED glows.
28. Step1: Connect the LED with arduino board and
breadboard.
Step2: Make the connection of wire between
arduino and breadboard.
Step3: Connect the LED with one pin of Arduino.
Step4: Connect the I/R sensor with arduino and
breadboard.
Step5: Connect the arduino with system.
Step6: Open the program in the arduino software.
Step7: Verify and upload the program and get the
output by placing your hand near the I/R Sensor.
29. Code-
int a=12;
int b=5;
void setup() {
// put your setup code here, to run once:
pinMode(a, INPUT);
pinMode(b, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int readsen=digitalRead(a);
if(readsen==HIGH)
{
digitalWrite(b, HIGH);
}
else
{
digitalWrite(b, !HIGH);
}
delay(1);
}
30. • Now its your turn do the same
practical with the use of any IOT
Platform.
31. Tasks to do-
• Make a system that sends mail to you
when the value of the sensor exceeds
the limit.(Hint-Explore Ubidots)
• Make a system that sends message
on your phone when the IR sensor
detects any presence.(Hint-Explore
Ubidots)