Home
About Us
Achievement
Home
Raspberry-Pi Projects
_Raspberry Pi 4 Complete Guide
Arduino Project
_All Projects
Esp8266 Project
_All Projects
Esp32 Project
_Automation-with-feedback
Arduino WorkShop
Just Do Electronics
February 24, 2020
Arduino WorkShop
1.Led Blink
Circuit Diagram
Code
//prateek //www.prateeks.in /* Blink a LED Turns on an LED on for one second, then off for one second, repeatedly. */ int led = 13; // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) delay(100); // wait for a second digitalWrite(led, LOW); // turn the LED off by making the voltage LOW delay(100); // wait for a second }
2.Read Switch and Display on LED
Circuit Diagram
Code
//prateek //www.prateeks.in /* Read Switch and Display on LED Turns on and off a light emitting diode(LED) connected to digital pin 13, when pressing a pushbutton attached to pin 2. */ 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); } }
3.Blink LED with POT
Circuit Diagram
Code
//prateek //www.prateeks.in /* Blink LED with POT Demonstrates analog input by reading an analog sensor on analog pin 0 and turning on and off a light emitting diode(LED) connected to digital pin 13. The amount of time the LED will be on and off depends on the value obtained by analogRead(). */ int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin, OUTPUT); } void loop() { // read the value from the sensor: sensorValue = analogRead(sensorPin); // turn the ledPin on digitalWrite(ledPin, HIGH); // stop the program for
milliseconds: delay(sensorValue); // turn the ledPin off: digitalWrite(ledPin, LOW); // stop the program for for
milliseconds: delay(sensorValue); }
4.
Measuring light Using LDR
Circuit Diagram
Code
//prateek //www.prateeks.in #define LDRpin A3 // pin where we connected the LDR and the resistor int LDRValue = 0; // result of reading the analog pin void setup() { Serial.begin(9600); // sets serial port for communication } void loop() { LDRValue = analogRead(LDRpin); // read the value from the LDR Serial.println(LDRValue); // print the value to the serial port delay(100); // wait a little }
5.
Automatic Street Light
Code
#include
int sensorPin=A0; int sensorValue = 0; int led = 3; void setup() { pinMode(led, OUTPUT); Serial.begin(9600); // put your setup code here, to run once: } void loop() { Serial.println("Welcome to LDR tutorial"); sensorValue = analogRead(sensorPin); Serial.println(sensorValue); if(sensorValue < 100) { Serial.println("LED light on"); digitalWrite(led,HIGH); delay(1000); } digitalWrite(led,LOW); delay(sensorValue); // put your main code here, to run repeatedly: }
6.What is temperature there
Circuit Diagram
Code
//prateek //www.prateeks.in /* What is temperature there with LM35 Reads an Temperature with LM35 Sensor . Also prints the results to the serial monitor. */ // These constants won't change. They're used to give names // to the pins used: const int analogInPin = A0; // Analog input pin that the LM35 is attached to const int analogOutPin = 9; // Analog output pin that the LED is attached to int sensorValue = 0; // value read from the LM35 int outputValue = 0; // value output to the PWM (analog out) void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); // map it to the range of the analog out: outputValue = map(sensorValue, 0, 1023, 0, 255); // change the analog out value: analogWrite(analogOutPin, outputValue); // print the results to the serial monitor: Serial.print("Voltage in mV = " ); Serial.print(sensorValue*5); Serial.print("\t Temperature in Degree Celsius = "); Serial.println(outputValue*2); // wait 2 milliseconds before the next loop // for the analog-to-digital converter to settle // after the last reading: delay(2); }
7.LM35 temperature sensor interfacing And Lcd
Code
//prateek //www.prateeks.in #include
#define LM35_pin 0 // LM35 output pin is connected to Arduino A0 pin // LCD module connections (RS, E, D4, D5, D6, D7) LiquidCrystal lcd(2, 3, 4, 5, 6, 7); void setup() { // set up the LCD's number of columns and rows lcd.begin(16, 2); lcd.setCursor(2, 0); lcd.print("Temperature:"); analogReference(INTERNAL); } float temp; char text[8]; void loop() { delay(1000); // Wait 1s between readings temp = analogRead(LM35_pin) / 9.3; // Read analog voltage and convert it to °C ( 9.3 = 1023/(1.1*100) ) sprintf(text, "%3u.%1u%cC", (int)temp, (int)(temp*10)%10, 223); lcd.setCursor(3, 1); lcd.print(text); }
Display letters, numbers and characters on LCD
Circuit Diagram
8.Code
//prateek //www.prateeks.in /* Display letters, numbers and fun characters on LCD The circuit: * LCD RS pin to digital pin 12 * LCD Enable pin to digital pin 11 * LCD D4 pin to digital pin 5 * LCD D5 pin to digital pin 4 * LCD D6 pin to digital pin 3 * LCD D7 pin to digital pin 2 * LCD R/W pin to ground * 10K resistor: * ends to +5V and ground * wiper to LCD VO pin (pin 3) */ // include the library code: #include
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.print("www.prateeks.in"); } void loop() { // Turn off the display: lcd.noDisplay(); delay(500); // Turn on the display: lcd.display(); delay(500); }
9. Light Intensity Measurement using LDR
Circuit Diagram
Code
//prateek //www.prateek.in #include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { //initialise for at least 2s lcd.begin(16, 2); lcd.print("INITIALISING"); delay(500); lcd.print("."); delay(500); lcd.print("."); delay(500); lcd.print("."); delay(500); lcd.print("."); delay(500); } void loop() { int sensorValue = analogRead(A0); double dV = sensorValue; double le = (dV/1023)*100; int level = le; lcd.clear(); lcd.setCursor(0, 0); lcd.print("LIGHT LEVEL:"); lcd.print(level); lcd.print("%"); lcd.setCursor(0, 1); if ((level >= 0) && (level <= 5)) { lcd.print("VERY DARK"); } else if ((level > 5) && (level <= 10)) { lcd.print("DARK"); } else if ((level > 10) && (level <= 50)) { lcd.print("BRIGHT"); } else { lcd.print("VERY BRIGHT"); } delay(500); }
10.Displaying Sensor Values on LCD
Code
//Prateek //www.prateeks.in #include
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(7,8,9,10,11,12); int potPin1 = A1; int potPin2 = A2; void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); lcd.clear(); pinMode(potPin1, INPUT); pinMode(potPin2, INPUT); } void loop() { lcd.setCursor(0,0); // Sets the cursor to col 0 and row 0 lcd.print("SensorVal1: "); // Prints Sensor Val: to LCD lcd.print(analogRead(potPin1)); // Prints value on Potpin1 to LCD lcd.setCursor(0,1); // Sets the cursor to col 1 and row 0 lcd.print("SensorVal2: "); // Prints Sensor Val: to LCD lcd.print(analogRead(potPin2)); // Prints value on Potpin1 to LCD }
0 Comments
Newer
Older
ESP32 Interfacing With LDR Sensor
How To Make RFID & Keypad Based Door Lock
IoT Based Fingerprint Biometric Attendance System Using NodeMCU (Esp8266)
Esp32 Cam Based Face Unlock
NRF Based Servo Motor Control
Ultrasonic Sensor as a Counter with Arduino
ESP32 Led Blink With Push Button
How to Make a Conveyor Belt System | Counter Machine
IoT Based Patient Health Monitoring System Using Blynk App
Arduino ebook
YouTube
Like on Facebook
Follow on Twitter
Follow on Google+
Follow on Instagram
Subscribe on Youtube
Hi WelCome To My Website If you have a creative mind and want to learn Electronics even without studying it then FRIENDS this Website And Youtube Channel is for you, I am crazy creators who love making Electronics things. I have a bunch of more than 130 Tutorial Videos on My YouTube Channel and I upload a new Tutorial every Sunday.
Tags
Arduino Project
Esp32 Project
Esp8266 Project
0 Comments