Pages: [1]   Go Down
Author Topic: Status Update.  (Read 450 times)
0 Members and 1 Guest are viewing this topic.
Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
young engineer of the future.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all. I just wanted to give you guys a status update. I've been messing around with my arduino and breaboard and some leds'. I'm still experimenting. I just wrote a new code that starts a serial connection with the pc(actually I rewrote an example code.. if the write command is sent to it. it will turn on or off the blue or red led.
 


Logged

Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 80
young engineer of the future.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
/*
  Physical Pixel

An example of using the Arduino board to receive data from the
computer.  In this case, the Arduino boards turns on an LED when
it receives the character 'H', and turns off the LED when it
receives the character 'L'.

The data can be sent from the Arduino serial monitor, or another
program like Processing (see code below), Flash (via a serial-net
proxy), PD, or Max/MSP.

The circuit:
* LED connected from digital pin 13 to ground

created 2006
by David A. Mellis
modified 14 Apr 2009
by Tom Igoe and Scott Fitzgerald

This example code is in the public domain.

http://www.arduino.cc/en/Tutorial/PhysicalPixel
*/

const int ledPin = 13; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
}

void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(13, HIGH);
    }
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L')
      digitalWrite(13, LOW);
     // see if there's incoming serial data:
  if (Serial.available() > 0)
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'h') {
      digitalWrite(12, HIGH);
    }
    // if it's an L (ASCII 76) turn off the LED:
Logged

Pages: [1]   Go Up
Jump to: