Add to this arduino sketch such that you can add three externally-connected LEDs to your circuit...

50.1K

Verified Solution

Question

Programming

Add to this arduino sketch such that you can add threeexternally-connected LEDs to your circuit board. Modify this codesuch that the first LED turns on if the ADC output value is between0 and 340, the second LED turns on if the ADC output value isbetween 341 and 680, and the third LED turns on if the ADC outputvalue is above 680

int potpin=0;// initialize analog pin 0int ledpin=13;// initialize digital pin 13int val=0;// define val, assign initial value 0void setup(){pinMode(ledpin,OUTPUT);// set digital pin as “output”Serial.begin(9600);// set baud rate at 9600}void loop(){digitalWrite(ledpin,HIGH);// turn on the LED on pin 13delay(50);// wait for 0.05 seconddigitalWrite(ledpin,LOW);// turn off the LED on pin 13delay(50);// wait for 0.05 secondval=analogRead(potpin);// read the analog value of analog pin 0, and assign it to val Serial.println(val);// display val’s value}

Answer & Explanation Solved by verified expert
4.5 Ratings (692 Votes)
Here our task is to create an arduino sketch to turn on and off3 LEDs according to the ADC input valuesThings to consider before codingWe have to define 3 variable to store arduino pin number inwhich 3 leds are going to be connectedled1led2led3 and set themas output pinsCreate    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students