Arduino Workshop 2011.05.31
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Arduino Workshop 2011.05.31

  • 1,674 views
Uploaded on

 

More in: Design
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,674
On Slideshare
1,674
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
77
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT);}void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second}
  • 2. void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT);}void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second}
  • 3. int brightness = 0;int fadeAmount = 5;void setup() { pinMode(9, OUTPUT);}void loop() { // set the brightness of pin 9: analogWrite(9, brightness); brightness = brightness + fadeAmount; if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } delay(30);}
  • 4. const int buttonPin = 2;const int ledPin = 13;int buttonState = 0;void setup() { pinMode(ledPin, OUTPUT); pinMode(buttonPin, INPUT);}void loop(){ // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); if (buttonState == HIGH) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }}
  • 5. const int sensorPin = A0;const int ledPin = 9;void setup() { pinMode(ledPin, OUTPUT);}void loop() { // read the value from the sensor: int sensorValue = analogRead(sensorPin); // scale from 0-1023 to 0-255 int intensity = map(sensorValue, 0, 1023, 0, 255); // sets the value analogWrite(ledPin, intensity);}
  • 6. const int ledPin = 9;void setup() { // initialize the serial communication: Serial.begin(9600); pinMode(ledPin, OUTPUT);}void loop() { byte brightness; // check if data has been sent from the computer: if (Serial.available()) { // read the most recent byte (0-255) brightness = Serial.read(); // set the brightness of the LED: analogWrite(ledPin, brightness); }}
  • 7. import processing.serial.*;Serial port;void setup() { size(256, 150); // Print available serial ports println(Serial.list()); port = new Serial(this, "COM1", 9600);}void draw() { // draw a gradient from black to white ... // send the current X-position of the mouse port.write(mouseX);}