0% found this document useful (0 votes)
19 views1 page

Prac 7

This document contains an Arduino sketch that sets up three output pins and listens for user input via the Serial interface. Depending on the input character ('g', 'r', or 'b'), it activates corresponding output pins with specific delays. The sketch runs indefinitely in a loop until interrupted.

Uploaded by

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

Prac 7

This document contains an Arduino sketch that sets up three output pins and listens for user input via the Serial interface. Depending on the input character ('g', 'r', or 'b'), it activates corresponding output pins with specific delays. The sketch runs indefinitely in a loop until interrupted.

Uploaded by

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

void setup()

{
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
char user_input;
void loop()
{
Serial.begin(9600);
while (1)
{
user_input = Serial.read();
if (user_input == 'g')
{
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
}
else if (user_input == 'r')
{
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
}
else if (user_input == 'b')
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
digitalWrite(9, HIGH);
delay(1000);
}
}
digitalWrite(9, LOW);
Serial.end();
};

You might also like