Programming Examples

Arduino Program to take input from serial and on the led based on input.


Arduino Code to On the LED based on Input

Arduino Program which accept the (R,G,Y) from Serial Input and On the Light Based on Given Input

void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(11,OUTPUT);
}
void loop()
{
	char ch;
  if(Serial.available())
  {
  ch=Serial.read();
  Serial.print(ch);
    if(ch=='r'||ch=='R')
    {
      digitalWrite(13,HIGH);
      digitalWrite(12,LOW);
      digitalWrite(11,LOW);
    }
    else if(ch=='g'||ch=='G')
    {
      digitalWrite(13,LOW);
      digitalWrite(12,HIGH);
      digitalWrite(11,LOW);
    }
    else if(ch=='y' ||ch=='Y' )
    {
      digitalWrite(13,LOW);
      digitalWrite(12,LOW);
      digitalWrite(11,HIGH);
    }
  }
}
Output

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad