AURDINO CODE 2.21 KB
Newer Older
B.Nagasuman's avatar
B.Nagasuman committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
int ledPin = 13;
String readString;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  Serial.println("serial on/off test 0021"); // so I can keep track
}

void loop() {

  while (Serial.available()) {
    delay(3); 
    char c = Serial.read();
    readString += c;
  }

  if (readString.length() >0) {
    Serial.println(readString);

    if (readString == "on")     
    {
      digitalWrite(ledPin, HIGH);
    }
    if (readString == "off")
    {
      digitalWrite(ledPin, LOW);
    }

    readString="";
  }
}char incomingByte;
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(D0,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
if(Serial.available()>0){
  incomingByte=Serial.read();
  if(incomingByte=='1')
{
  digitalWrite(D0,HIGH);
}
else if(incomingByte=='0'){
digitalWrite(D0,LOW);
}
//say what you got:
Serial.print("I received:");
Serial.println(incomingByte,DEC);
delay(10);
}void setup() {
// initialize digital pin 16 as an output.
pinMode(16, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(16, LOW); // turn the LED off by making the voltage LOW
delay(100); // wait for 1/10 secon
}}
                      PROGRAM D
                       char IncomingByte;
//int serial;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0)
  {
    IncomingByte=Serial.read();
  Serial.print("I HAVE RECEIVED");
  Serial.println(IncomingByte,DEC);
  delay(10);}

}
                       PROGRAM E
char incomingByte;
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(D0,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
if(Serial.available()>0){
  incomingByte=Serial.read();
  if(incomingByte=='1')
{
  digitalWrite(D0,HIGH);
}
else if(incomingByte=='0'){
digitalWrite(D0,LOW);
}
//say what you got:
Serial.print("I received:");
Serial.println(incomingByte,DEC);
delay(10);
}
}
                     
                   PROGRAM B