• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Arduino Workshop 2011.05.31
 

Arduino Workshop 2011.05.31

on

  • 1,439 views

 

Statistics

Views

Total Views
1,439
Views on SlideShare
1,439
Embed Views
0

Actions

Likes
0
Downloads
69
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Arduino Workshop 2011.05.31 Arduino Workshop 2011.05.31 Presentation Transcript

    • 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}
    • 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}
    • 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);}
    • 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); }}
    • 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);}
    • 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); }}
    • 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);}