Skip to content

Commit

Permalink
updated examples and libraries for Arduino 1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tzikis committed Jul 31, 2013
1 parent 10c22bb commit d609b4a
Show file tree
Hide file tree
Showing 486 changed files with 44,156 additions and 6,938 deletions.
22 changes: 22 additions & 0 deletions examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor.
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}
File renamed without changes.
24 changes: 24 additions & 0 deletions examples/01.Basics/Blink/Blink.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
29 changes: 29 additions & 0 deletions examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
DigitalReadSerial
Reads a digital input on pin 2, prints the result to the serial monitor
This example code is in the public domain.
*/

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// make the pushbutton's pin an input:
pinMode(pushButton, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
delay(1); // delay in between reads for stability
}



10 changes: 7 additions & 3 deletions examples/1.Basics/Fade/Fade.ino → examples/01.Basics/Fade/Fade.ino
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
using the analogWrite() function.
This example code is in the public domain.
*/

int led = 9; // the pin that the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(9, OUTPUT);
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(9, brightness);
analogWrite(led, brightness);

// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
Expand All @@ -29,3 +32,4 @@ void loop() {
// wait for 30 milliseconds to see the dimming effect
delay(30);
}

23 changes: 23 additions & 0 deletions examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
ReadAnalogVoltage
Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
}
File renamed without changes.
File renamed without changes.
26 changes: 20 additions & 6 deletions examples/2.Digital/Debounce/Debounce.ino → examples/02.Digital/Debounce/Debounce.ino
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
by David A. Mellis
modified 30 Aug 2011
by Limor Fried
modified 28 Dec 2012
by Mike Walters
This example code is in the public domain.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Debounce
*/

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// Variables will change:
int ledState = HIGH; // the current state of the output pin
Expand All @@ -43,6 +45,9 @@ long debounceDelay = 50; // the debounce time; increase if the output flicker
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);

// set initial LED state
digitalWrite(ledPin, ledState);
}

void loop() {
Expand All @@ -62,11 +67,20 @@ void loop() {
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonState = reading;

// if the button state has changed:
if (reading != buttonState) {
buttonState = reading;

// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH) {
ledState = !ledState;
}
}
}

// set the LED using the state of the button:
digitalWrite(ledPin, buttonState);
// set the LED:
digitalWrite(ledPin, ledState);

// save the reading. Next time through the loop,
// it'll be the lastButtonState:
Expand Down
52 changes: 52 additions & 0 deletions examples/02.Digital/DigitalInputPullup/DigitalInputPullup.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Input Pullup Serial
This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a
digital input on pin 2 and prints the results to the serial monitor.
The circuit:
* Momentary switch attached from pin 2 to ground
* Built-in LED on pin 13
Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
20K-ohm resistor is pulled to 5V. This configuration causes the input to
read HIGH when the switch is open, and LOW when it is closed.
created 14 March 2012
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/InputPullupSerial
This example code is in the public domain
*/

void setup(){
//start serial connection
Serial.begin(9600);
//configure pin2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
pinMode(13, OUTPUT);

}

void loop(){
//read the pushbutton value into a variable
int sensorVal = digitalRead(2);
//print out the value of the pushbutton
Serial.println(sensorVal);

// Keep in mind the pullup means the pushbutton's
// logic is inverted. It goes HIGH when it's open,
// and LOW when it's pressed. Turn on pin 13 when the
// button's pressed, and off when it's not:
if (sensorVal == HIGH) {
digitalWrite(13, LOW);
}
else {
digitalWrite(13, HIGH);
}
}



File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* 8-ohm speaker on digital pin 8
created 21 Jan 2010
modified 30 Aug 2011
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
Expand Down Expand Up @@ -41,5 +41,4 @@ void loop() {
tone(8, notes[thisSensor], 20);
}
}
Serial.println();
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* 4.7K resistor on analog 0 to ground
created 21 Jan 2010
modified 30 Aug 2011
by Tom Igoe
modified 31 May 2012
by Tom Igoe, with suggestion from Michael Flynn
This example code is in the public domain.
Expand All @@ -29,14 +29,15 @@ void loop() {
int sensorReading = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorReading);
// map the pitch to the range of the analog input.
// map the analog input range (in this case, 400 - 1000 from the photoresistor)
// to the output pitch range (120 - 1500Hz)
// change the minimum and maximum input numbers below
// depending on the range your sensor's giving:
int thisPitch = map(sensorReading, 400, 1000, 100, 1000);
int thisPitch = map(sensorReading, 400, 1000, 120, 1500);

// play the pitch:
tone(9, thisPitch, 10);

delay(1); // delay in between reads for stability
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* LED connected from digital pin 9 to ground
created 29 Dec. 2008
modified 30 Aug 2011
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
Expand Down Expand Up @@ -46,8 +46,8 @@ void loop() {
Serial.print("\t output = ");
Serial.println(outputValue);

// wait 10 milliseconds before the next loop
// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(10);
delay(2);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions examples/3.Analog/Smoothing/Smoothing.ino → examples/03.Analog/Smoothing/Smoothing.ino
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* Analog sensor (potentiometer will do) attached to analog input 0
Created 22 April 2007
modified 30 Aug 2011
By David A. Mellis <dam@mellis.org>
modified 9 Apr 2012
by Tom Igoe
http://www.arduino.cc/en/Tutorial/Smoothing
This example code is in the public domain.
Expand Down Expand Up @@ -61,7 +61,8 @@ void loop() {
// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
Serial.println(average);
Serial.println(average);
delay(1); // delay in between reads for stability
}


Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@
created 2006
by Nicholas Zambetti
modified 30 Aug 2011
modified 9 Apr 2012
by Tom Igoe
This example code is in the public domain.
<http://www.zambetti.com>
*/
void setup()
{
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);

while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

// prints title with ending line break
Serial.println("ASCII Table ~ Character Map");
}
Expand All @@ -33,8 +36,7 @@ int thisByte = 33;
// for example. '!' is the same as 33, so you could also use this:
//int thisByte = '!';

void loop()
{
void loop() {
// prints value unaltered, i.e. the raw binary version of the
// byte. The serial monitor interprets all bytes as
// ASCII, so 33, the first number, will show up as '!'
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/4.Communication/Graph/Graph.ino → examples/04.Communication/Graph/Graph.ino
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
created 2006
by David A. Mellis
modified 30 Aug 2011
modified 9 Apr 2012
by Tom Igoe and Scott Fitzgerald
This example code is in the public domain.
Expand All @@ -36,7 +36,7 @@ void loop() {
Serial.println(analogRead(A0));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(10);
delay(2);
}

/* Processing code for this example
Expand Down
4 changes: 2 additions & 2 deletions examples/4.Communication/MIDI/Midi.ino → examples/04.Communication/MIDI/Midi.ino
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
Attach a MIDI cable to the jack, then to a MIDI synth, and play music.
created 13 Jun 2006
modified 30 Aug 2011
modified 13 Aug 2012
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/MIDI
http://www.arduino.cc/en/Tutorial/Midi
*/

Expand Down
Loading

0 comments on commit d609b4a

Please sign in to comment.