0% found this document useful (0 votes)
13 views

Simulation Using Arduino

The document describes a simulation using an Arduino to control LEDs based on light detected by a light dependent resistor (LDR). It initializes 8 LEDs and an LCD screen as outputs. It reads the LDR value, maps it to a number between 0-255, and displays this on the LCD. It then turns the LEDs on sequentially as the LDR value increases, and off sequentially as the LDR value decreases, simulating a light meter.

Uploaded by

Mian Tauseef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Simulation Using Arduino

The document describes a simulation using an Arduino to control LEDs based on light detected by a light dependent resistor (LDR). It initializes 8 LEDs and an LCD screen as outputs. It reads the LDR value, maps it to a number between 0-255, and displays this on the LCD. It then turns the LEDs on sequentially as the LDR value increases, and off sequentially as the LDR value decreases, simulating a light meter.

Uploaded by

Mian Tauseef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Simulation using Arduino:

#include <LiquidCrystal.h>

int led7 = 7;

int led6 = 6;

int led5 = 5;

int led4 = 4;

int led3 = 3;

int led2 = 2;

int led1 = 1;

int led0 = 0;

LiquidCrystal lcd (13,12,11,10,9,8);

void setup() {

// put your setup code here, to run once:

lcd.begin (16,2);

pinMode(led0,OUTPUT);

pinMode(led1,OUTPUT);

pinMode(led2,OUTPUT);

pinMode(led3,OUTPUT);

pinMode(led4,OUTPUT);

pinMode(led5,OUTPUT);

pinMode(led6,OUTPUT);

pinMode(led7,OUTPUT);

void loop() {
// put your main code here, to run repeatedly:

int LDR =analogRead(A0);

int temp=map (LDR,0,1023,0,255);

lcd.setCursor(0,0);

lcd.print("ADC VALUE = ");

lcd.setCursor(0,1);

lcd.print(temp);

delay(10);

lcd.clear();

if (LDR==0){

digitalWrite(led1,LOW);

digitalWrite(led2,LOW);

digitalWrite(led3,LOW);

digitalWrite(led4,LOW);

digitalWrite(led5,LOW);

digitalWrite(led6,LOW);

digitalWrite(led7,LOW);

//////////LED ON Condition//////////

if (LDR>0){

digitalWrite (led7,HIGH);

if (LDR>32){

digitalWrite (led6,HIGH);

}
if (LDR>64){

digitalWrite (led5,HIGH);

if (LDR>96){

digitalWrite (led4,HIGH);

if (LDR>128){

digitalWrite (led3,HIGH);

if (LDR>160){

digitalWrite (led2,HIGH);

if (LDR>192){

digitalWrite (led1,HIGH);

if (LDR>224){

digitalWrite (led0,HIGH);

//////////LED OFF Condition//////////

if (LDR<0){

digitalWrite (led7,LOW);

if (LDR<32){

digitalWrite (led6,LOW);

}
if (LDR<64){

digitalWrite (led5,LOW);

if (LDR<96){

digitalWrite (led4,LOW);

if (LDR<128){

digitalWrite (led3,LOW);

if (LDR<160){

digitalWrite (led2,LOW);

if (LDR<192){

digitalWrite (led1,LOW);

if (LDR<224){

digitalWrite (led0,LOW);

}
Specfication of Arduino Nano:

Microcontroller ATMega328/ATMega
Operating Voltage 2.7 to 5.5 V
Input Voltage(recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 14(of which 6 provide PWM output)
Analog Input Pins 8(A0-A7)
DC Current per I/O Pin 40 MA
DC Current for 3.3V Pin 50mA
Flash Memory 32 KB of which 0.5 KB
SRAM 2 KB
EEPROM 1 KB
Clock Speed 16MHz
Temperature Range is –40°C to +125°C
Power Consumes low power up to 1.5mA at 3V - 4MHz
Length 68.6mm
Width 53.4mm
Weight 25g

Operating Voltage 3.3 to 5V DC


Operating Voltage 15mA
Output Digital DO 0V-5V, Adjustable Trigger Level from present
Output Analog AO 0V-5V, Based on light falling on the LDR
Indicator Output Indicator(LEDs)and Power Indicator (Red Light)
PCB Size 3.2cm x 1.4cm
Design LM393

You might also like