Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following are simple assignments I just need help especially with learning h

ID: 2249776 • Letter: T

Question

The following are simple assignments I just need help especially with learning how to execute these in arduino IDE. Explanations and comments of each line of code would be much appreciated.

1. Write an Arduino script to make a single LED blink on and off at a rate of 1 Hz (1/2 second on; ½ second off; repeat continuously).

2. For this exercise, you need two LED’s, one RED and the other GREEN. Program the Arduino to control the LEDs in the following sequence: (a) RED LED glows for 1 second; (b) GREEN LED glows for 2 seconds; (c)RED LEDs glows for 3 seconds (d) GREEN LED glows for 4 seconds REPEAT (a) – (d) continuously

3. Write an Arduino script that will move your car forward for 5 seconds, backward for 3 seconds, then repeat continuously. Test your circuit on your car.

Explanation / Answer

1 question Answer

// This Arduino sketch , blinking led 1/2 second ON , 1/2 OFF

int led = 10; //Say led pin connected to GPIO pin 10
void setup()
{
Serial.begin(9600); //beginning Serail to print on monitor
pinMode(led,OUTPUT); //led glowing so it is output
}

void loop()
{
digitalWrite(led,HIGH); //making high
Serial.println("LED is HiGH");
delay(500); // it turns on for 500 msec i.e half second
digitalWrite(led,LOW); //making high
Serial.println("LED is LOW");
delay(500); // it turns on for 500 msec i.e half second

}

2 Answer

// This Arduino sketch , blinking RED and green leds

int r_led = 10; //Say RED led pin connected to GPIO pin 10
int g_led = 11; //Say GREEN led pin connected to GPIO pin 10
void setup()
{
Serial.begin(9600); //beginning Serail to print on monitor
pinMode(r_led,OUTPUT); //led glowing so it is output
pinMode(g_led,OUTPUT); //led glowing so it is output
}

void loop()
{
digitalWrite(r_led,HIGH); //making RED led high
digitalWrite(g_led,LOW);
Serial.println("RED LED is HiGH for one second");
delay(1000); //

digitalWrite(r_led,LOW); //making RED led low
digitalWrite(g_led,HIGH); //making green led glow
Serial.println("Grenn LED is HiGH for two seconds");
delay(2000); //


digitalWrite(g_led,LOW); //making green led low
digitalWrite(r_led,HIGH); //making RED led high
Serial.println("RED LED is HiGH for three seconds");
delay(3000); //

digitalWrite(r_led,LOW); //making RED led low
digitalWrite(g_led,HIGH); //making green led glow
Serial.println("Grenn LED is HiGH for four seconds");
delay(4000); //

}

3.

int led = 10; //Motor is connected to digital pin 10
void setup()
{
Serial.begin(9600); //beginning Serail to print on monitor
pinMode(led,OUTPUT); //motor is output
}

void loop()
{
digitalWrite(led,HIGH); //making high
Serial.println("motor running in fwd direction");
delay(5000); // IT moves forward direction for 5 sec
digitalWrite(led,LOW); //making high
Serial.println("motor running in backward direction");
delay(3000); // IT moves backward direction for 3 sec

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote