SlideShare a Scribd company logo
1 of 46
Download to read offline
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);
}
Arduino Workshop 2011.05.31

More Related Content

What's hot

Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gates
Ricardo Castro
 
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Irfan Qadoos
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
Tom Paulus
 

What's hot (20)

Arduino Workshop Day 2
Arduino  Workshop Day 2Arduino  Workshop Day 2
Arduino Workshop Day 2
 
Cassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshopCassiopeia Ltd - standard Arduino workshop
Cassiopeia Ltd - standard Arduino workshop
 
Aurduino coding for transformer interfacing
Aurduino coding for transformer interfacingAurduino coding for transformer interfacing
Aurduino coding for transformer interfacing
 
Scottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RADScottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RAD
 
Arduino Day 1 Presentation
Arduino Day 1 PresentationArduino Day 1 Presentation
Arduino Day 1 Presentation
 
DSL Junior Makers - electronics workshop
DSL Junior Makers - electronics workshopDSL Junior Makers - electronics workshop
DSL Junior Makers - electronics workshop
 
Arduino 8-step drum sequencer 3 channels
Arduino 8-step drum sequencer 3 channelsArduino 8-step drum sequencer 3 channels
Arduino 8-step drum sequencer 3 channels
 
arduino
arduinoarduino
arduino
 
Experimentdsd[1]
Experimentdsd[1]Experimentdsd[1]
Experimentdsd[1]
 
Chap 3
Chap 3Chap 3
Chap 3
 
Task i
Task iTask i
Task i
 
Experiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gatesExperiment write-vhdl-code-for-realize-all-logic-gates
Experiment write-vhdl-code-for-realize-all-logic-gates
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
 
Digital system design lab manual
Digital system design lab manualDigital system design lab manual
Digital system design lab manual
 
Logic gates
Logic gatesLogic gates
Logic gates
 
Temperature sensor with a led matrix display (arduino controlled)
Temperature sensor with a led matrix display (arduino controlled)Temperature sensor with a led matrix display (arduino controlled)
Temperature sensor with a led matrix display (arduino controlled)
 
Logical Gates
Logical GatesLogical Gates
Logical Gates
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
 
Up and running with Teensy 3.1
Up and running with Teensy 3.1Up and running with Teensy 3.1
Up and running with Teensy 3.1
 

Viewers also liked

111125 ものづくりオープンメソッドiamas・岐阜高専連携講座 takawo
111125 ものづくりオープンメソッドiamas・岐阜高専連携講座 takawo111125 ものづくりオープンメソッドiamas・岐阜高専連携講座 takawo
111125 ものづくりオープンメソッドiamas・岐阜高専連携講座 takawo
takawo shunsuke
 
IAMAS 2010 First presentation
IAMAS 2010 First presentationIAMAS 2010 First presentation
IAMAS 2010 First presentation
ocrock
 
IAMAS Innovation Studio Opening 2013.04.19
IAMAS Innovation Studio Opening 2013.04.19IAMAS Innovation Studio Opening 2013.04.19
IAMAS Innovation Studio Opening 2013.04.19
Shigeru Kobayashi
 

Viewers also liked (12)

平成23年度メディア芸術部門会議
平成23年度メディア芸術部門会議平成23年度メディア芸術部門会議
平成23年度メディア芸術部門会議
 
Make:r × Maker - 0th Exhibition
Make:r × Maker - 0th ExhibitionMake:r × Maker - 0th Exhibition
Make:r × Maker - 0th Exhibition
 
111125 ものづくりオープンメソッドiamas・岐阜高専連携講座 takawo
111125 ものづくりオープンメソッドiamas・岐阜高専連携講座 takawo111125 ものづくりオープンメソッドiamas・岐阜高専連携講座 takawo
111125 ものづくりオープンメソッドiamas・岐阜高専連携講座 takawo
 
「Makerムーブメント」の時代におけるデザイン言語
「Makerムーブメント」の時代におけるデザイン言語「Makerムーブメント」の時代におけるデザイン言語
「Makerムーブメント」の時代におけるデザイン言語
 
iBeaconハッカソン
iBeaconハッカソンiBeaconハッカソン
iBeaconハッカソン
 
20131026 i beaconワークショップ
20131026 i beaconワークショップ20131026 i beaconワークショップ
20131026 i beaconワークショップ
 
公共の場での体験型作品展示 〜屋外で観客を誘導するためのKinect〜
公共の場での体験型作品展示 〜屋外で観客を誘導するためのKinect〜公共の場での体験型作品展示 〜屋外で観客を誘導するためのKinect〜
公共の場での体験型作品展示 〜屋外で観客を誘導するためのKinect〜
 
フィジカルコンピューティングとその可能性
フィジカルコンピューティングとその可能性フィジカルコンピューティングとその可能性
フィジカルコンピューティングとその可能性
 
IAMAS 2010 First presentation
IAMAS 2010 First presentationIAMAS 2010 First presentation
IAMAS 2010 First presentation
 
IAMAS Innovation Studio Opening 2013.04.19
IAMAS Innovation Studio Opening 2013.04.19IAMAS Innovation Studio Opening 2013.04.19
IAMAS Innovation Studio Opening 2013.04.19
 
「Makerムーブメント」の時代におけるdesign、学び、産業
「Makerムーブメント」の時代におけるdesign、学び、産業「Makerムーブメント」の時代におけるdesign、学び、産業
「Makerムーブメント」の時代におけるdesign、学び、産業
 
2013 Maker Meetup Taipei
2013 Maker Meetup Taipei2013 Maker Meetup Taipei
2013 Maker Meetup Taipei
 

Similar to Arduino Workshop 2011.05.31

Mims effect
Mims effectMims effect
Mims effect
arnaullb
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
SIGMATAX1
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 
Mao arduino
Mao arduinoMao arduino
Mao arduino
Mao Wu
 
Lab_5.txt.rtfLab_05Design an application that reads the .docx
Lab_5.txt.rtfLab_05Design an application that reads the .docxLab_5.txt.rtfLab_05Design an application that reads the .docx
Lab_5.txt.rtfLab_05Design an application that reads the .docx
DIPESH30
 

Similar to Arduino Workshop 2011.05.31 (20)

Mims effect
Mims effectMims effect
Mims effect
 
Introduction to arduino Programming with
Introduction to arduino Programming withIntroduction to arduino Programming with
Introduction to arduino Programming with
 
Arduino.pptx
Arduino.pptxArduino.pptx
Arduino.pptx
 
Arduino cic3
Arduino cic3Arduino cic3
Arduino cic3
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingRoberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Arduino based applications part 1
Arduino based applications part 1Arduino based applications part 1
Arduino based applications part 1
 
Bluetooth
Bluetooth Bluetooth
Bluetooth
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 
Arduino final ppt
Arduino final pptArduino final ppt
Arduino final ppt
 
Arduino for Beginners
Arduino for BeginnersArduino for Beginners
Arduino for Beginners
 
Mao arduino
Mao arduinoMao arduino
Mao arduino
 
Day1
Day1Day1
Day1
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Lab_5.txt.rtfLab_05Design an application that reads the .docx
Lab_5.txt.rtfLab_05Design an application that reads the .docxLab_5.txt.rtfLab_05Design an application that reads the .docx
Lab_5.txt.rtfLab_05Design an application that reads the .docx
 
Arduino programming part1
Arduino programming part1Arduino programming part1
Arduino programming part1
 
P-Space Arduino/Genuino day 2016
P-Space Arduino/Genuino day 2016P-Space Arduino/Genuino day 2016
P-Space Arduino/Genuino day 2016
 

More from Shigeru Kobayashi

情報学基礎:エレクトロニクス
情報学基礎:エレクトロニクス情報学基礎:エレクトロニクス
情報学基礎:エレクトロニクス
Shigeru Kobayashi
 
Engadget電子工作部:インテルGalileoでガジェットを作ろう!
Engadget電子工作部:インテルGalileoでガジェットを作ろう!Engadget電子工作部:インテルGalileoでガジェットを作ろう!
Engadget電子工作部:インテルGalileoでガジェットを作ろう!
Shigeru Kobayashi
 

More from Shigeru Kobayashi (20)

Maker Faireを持続可能にするには?
Maker Faireを持続可能にするには?Maker Faireを持続可能にするには?
Maker Faireを持続可能にするには?
 
Maker Faire Tokyo 2018
Maker Faire Tokyo 2018Maker Faire Tokyo 2018
Maker Faire Tokyo 2018
 
IoT Workshop in Macao
IoT Workshop in MacaoIoT Workshop in Macao
IoT Workshop in Macao
 
au未来研究所ハッカソン
au未来研究所ハッカソンau未来研究所ハッカソン
au未来研究所ハッカソン
 
Maker Faire Tokyo 2015
Maker Faire Tokyo 2015Maker Faire Tokyo 2015
Maker Faire Tokyo 2015
 
Gesture Workshop
Gesture WorkshopGesture Workshop
Gesture Workshop
 
Telematics Hackathon
Telematics HackathonTelematics Hackathon
Telematics Hackathon
 
テレマティクスハッカソン参加同意書
テレマティクスハッカソン参加同意書テレマティクスハッカソン参加同意書
テレマティクスハッカソン参加同意書
 
monoFab Ideathon Meeting
monoFab Ideathon MeetingmonoFab Ideathon Meeting
monoFab Ideathon Meeting
 
monoFabアイデアソンミーティング参加同意書
monoFabアイデアソンミーティング参加同意書monoFabアイデアソンミーティング参加同意書
monoFabアイデアソンミーティング参加同意書
 
CEATEC JAPAN 2014
CEATEC JAPAN 2014CEATEC JAPAN 2014
CEATEC JAPAN 2014
 
BLE Boot Camp
BLE Boot CampBLE Boot Camp
BLE Boot Camp
 
Fab MeetUp Vol.5
Fab MeetUp Vol.5Fab MeetUp Vol.5
Fab MeetUp Vol.5
 
SK creator planet 2014
SK creator planet 2014SK creator planet 2014
SK creator planet 2014
 
Solid 2014 kobayashi
Solid 2014 kobayashiSolid 2014 kobayashi
Solid 2014 kobayashi
 
情報学基礎:エレクトロニクス
情報学基礎:エレクトロニクス情報学基礎:エレクトロニクス
情報学基礎:エレクトロニクス
 
Rebuilding the world, from the 'periphery'
Rebuilding the world, from the 'periphery'Rebuilding the world, from the 'periphery'
Rebuilding the world, from the 'periphery'
 
Engadget電子工作部:インテルGalileoでガジェットを作ろう!
Engadget電子工作部:インテルGalileoでガジェットを作ろう!Engadget電子工作部:インテルGalileoでガジェットを作ろう!
Engadget電子工作部:インテルGalileoでガジェットを作ろう!
 
第2回iBeaconハッカソン
第2回iBeaconハッカソン第2回iBeaconハッカソン
第2回iBeaconハッカソン
 
イノベーション創出のファシリテータとしてのデジタル工作機械を備えた市民工房
イノベーション創出のファシリテータとしてのデジタル工作機械を備えた市民工房イノベーション創出のファシリテータとしてのデジタル工作機械を備えた市民工房
イノベーション創出のファシリテータとしてのデジタル工作機械を備えた市民工房
 

Recently uploaded

Presentation on 3D Printing.pptx presentation
Presentation on 3D Printing.pptx presentationPresentation on 3D Printing.pptx presentation
Presentation on 3D Printing.pptx presentation
ajroy0196
 
一比一原版格林威治大学毕业证成绩单如何办理
一比一原版格林威治大学毕业证成绩单如何办理一比一原版格林威治大学毕业证成绩单如何办理
一比一原版格林威治大学毕业证成绩单如何办理
cyebo
 
一比一原版谢菲尔德大学毕业证成绩单如何办理
一比一原版谢菲尔德大学毕业证成绩单如何办理一比一原版谢菲尔德大学毕业证成绩单如何办理
一比一原版谢菲尔德大学毕业证成绩单如何办理
cyebo
 
Heuristic Evaluation of System & Application
Heuristic Evaluation of System & ApplicationHeuristic Evaluation of System & Application
Heuristic Evaluation of System & Application
Jaime Brown
 

Recently uploaded (20)

Presentation on 3D Printing.pptx presentation
Presentation on 3D Printing.pptx presentationPresentation on 3D Printing.pptx presentation
Presentation on 3D Printing.pptx presentation
 
FW25-26 Fashion Key Items Trend Book Peclers Paris
FW25-26 Fashion Key Items Trend Book Peclers ParisFW25-26 Fashion Key Items Trend Book Peclers Paris
FW25-26 Fashion Key Items Trend Book Peclers Paris
 
BIT Khushi gandhi project.pdf graphic design
BIT Khushi gandhi project.pdf graphic designBIT Khushi gandhi project.pdf graphic design
BIT Khushi gandhi project.pdf graphic design
 
spColumn-Manual design column by spcolumn software.pdf
spColumn-Manual design column by spcolumn software.pdfspColumn-Manual design column by spcolumn software.pdf
spColumn-Manual design column by spcolumn software.pdf
 
The Impact of Artificial Intelligence on Modern Healthcare.pptx
The Impact of Artificial Intelligence on Modern Healthcare.pptxThe Impact of Artificial Intelligence on Modern Healthcare.pptx
The Impact of Artificial Intelligence on Modern Healthcare.pptx
 
一比一原版格林威治大学毕业证成绩单如何办理
一比一原版格林威治大学毕业证成绩单如何办理一比一原版格林威治大学毕业证成绩单如何办理
一比一原版格林威治大学毕业证成绩单如何办理
 
Recycled Modular Low Cost Construction .pdf
Recycled Modular Low Cost Construction .pdfRecycled Modular Low Cost Construction .pdf
Recycled Modular Low Cost Construction .pdf
 
Abdulaziz Tariq Abdulaziz Mustafa CV 2024
Abdulaziz Tariq Abdulaziz Mustafa CV 2024Abdulaziz Tariq Abdulaziz Mustafa CV 2024
Abdulaziz Tariq Abdulaziz Mustafa CV 2024
 
Spring 2024 wkrm_Enhancing Campus Mobility.pdf
Spring 2024 wkrm_Enhancing Campus Mobility.pdfSpring 2024 wkrm_Enhancing Campus Mobility.pdf
Spring 2024 wkrm_Enhancing Campus Mobility.pdf
 
iF_Design_Trend_Report_twentytwenrythree
iF_Design_Trend_Report_twentytwenrythreeiF_Design_Trend_Report_twentytwenrythree
iF_Design_Trend_Report_twentytwenrythree
 
Design Portofolios - Licensed Architect / BIM Specialist
Design Portofolios - Licensed Architect / BIM SpecialistDesign Portofolios - Licensed Architect / BIM Specialist
Design Portofolios - Licensed Architect / BIM Specialist
 
Claire's designing portfolio presentation
Claire's designing portfolio presentationClaire's designing portfolio presentation
Claire's designing portfolio presentation
 
Week of Action 2022_EIT Climate-KIC_Headers
Week of Action 2022_EIT Climate-KIC_HeadersWeek of Action 2022_EIT Climate-KIC_Headers
Week of Action 2022_EIT Climate-KIC_Headers
 
Design lessons from Singapore | Volume 3
Design lessons from Singapore | Volume 3Design lessons from Singapore | Volume 3
Design lessons from Singapore | Volume 3
 
Heidi Livengood's Professional CADD Portfolio
Heidi Livengood's Professional CADD PortfolioHeidi Livengood's Professional CADD Portfolio
Heidi Livengood's Professional CADD Portfolio
 
Bit Dhrumi shah Graphic Designer portfolio
Bit Dhrumi shah Graphic Designer portfolioBit Dhrumi shah Graphic Designer portfolio
Bit Dhrumi shah Graphic Designer portfolio
 
一比一原版谢菲尔德大学毕业证成绩单如何办理
一比一原版谢菲尔德大学毕业证成绩单如何办理一比一原版谢菲尔德大学毕业证成绩单如何办理
一比一原版谢菲尔德大学毕业证成绩单如何办理
 
Heuristic Evaluation of System & Application
Heuristic Evaluation of System & ApplicationHeuristic Evaluation of System & Application
Heuristic Evaluation of System & Application
 
NO1 Popular kala jadu karne wale ka contact number kala jadu karne wale baba ...
NO1 Popular kala jadu karne wale ka contact number kala jadu karne wale baba ...NO1 Popular kala jadu karne wale ka contact number kala jadu karne wale baba ...
NO1 Popular kala jadu karne wale ka contact number kala jadu karne wale baba ...
 
Eric Parein CV. Parein in English is best pronounced as PARE-IN
Eric Parein CV. Parein in English is best pronounced as PARE-INEric Parein CV. Parein in English is best pronounced as PARE-IN
Eric Parein CV. Parein in English is best pronounced as PARE-IN
 

Arduino Workshop 2011.05.31

  • 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. 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 }
  • 27. 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 }
  • 28.
  • 29.
  • 30. 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); }
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. 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); } }
  • 36.
  • 37.
  • 38.
  • 39.
  • 40. 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); }
  • 41.
  • 42.
  • 43.
  • 44. 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); } }
  • 45. 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); }