Labels

Sunday, June 2, 2013

Arduino

 Arduino
The code will be done with arduino

some code listings that i found as a guide.


int outPin = 12; // Output connected to digital pin 12
int mail = LOW; // Is there new mail?
int val; // Value read from the serial port

void setup()
{
    pinMode(outPin, OUTPUT); // sets the digital pin as output
    Serial.begin(9600);
    Serial.flush();
}

void loop()
{
    // Read from serial port
    if (Serial.available())
    {
        val = Serial.read();
        Serial.println(val);
        if (val == 'M') mail = HIGH;
        else if (val == 'N') mail = LOW;
    }

    // Set the status of the output pin
    digitalWrite(outPin, mail);
}

No comments:

Post a Comment