Arduinobasic
Arduinobasic
1. done
2. 2.2 ohm and 100 ohm
3. 1.Green black black red silver
2. black black brown black brown
3. yellow green black orange red
Exercise 2
To have an operating voltage of 2.2V through the led, the resistor needs to “take”
2.8 V. Combining that with the requirement of 13 mA, the value of the resistor is
(R=U/I, 2.8/0.013)= 215 ohm for practicality reasons using a 220 ohm resistor is
fine. It does leads to a voltage of 2.86 and not the demanded one of 2.8 V.
Otherwise a the single resistor can be replaced by multiples in series to get a
more accurate voltage( 200 ohms+10 ohms+5 ohms)
Exercise 3
The circuit diagram is presented in exercise 2:
Exercise 4: Install the Arduino IDE on your computer
Questions: Make your LED flash by using the Arduino Change the following connection:
Source: https://thecustomizewindows.com/2018/07/arduino-blink-two-leds-alternatively/
Source: https://arduinotogo.com/2017/02/28/chapter-6-potentiometer-circuit-step-by-step/
Exercise 10: Light in the dark
Source: https://create.arduino.cc/projecthub/guruashishchoudhary29/turn-led-on-and-off-through-
ldr-fe5738
Extra exercise 1
Code:
// basic functions
int GREEN = 2;
int YELLOW = 3;
int RED = 4;
void setup()
pinMode(GREEN, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(RED, OUTPUT);
void loop()
{
Serial.begin(9600);
digitalWrite(RED, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(GREEN, LOW);
delay(2000);
digitalWrite(YELLOW, HIGH);
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
delay(2000);
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, LOW);
delay(2000);
}
Circuit(except instead of 330 ohms I used 470 ohm resistors):
https://www.kindpng.com/imgv/TwRbbxo_simple-traffic-light-diagram-hd-png-download/
extra exercise 2
circuit(expect 5 leds/buttons instead of 6):
Code:
int index_state = 0;
int record_count = 0;
void setup()
pinMode(button[i],INPUT);
pinMode(leds[i],OUTPUT);
pinMode(record_led, OUTPUT);
pinMode(play_led, OUTPUT);
empty=true;
Serial.begin(9600);
void playback(){
for(int i = 0; i<10; i++){ //set the appropriate LED HIGH then LOW according to sequence array
if (arr[i]!=7){
digitalWrite(leds[arr[i]],HIGH);
delay(250);
digitalWrite(leds[arr[i]],LOW);
delay(250);
digitalWrite(play_led,LOW);
void loop(){
playback();