diff options
| author | Sudar <sudar@sudarmuthu.com> | 2014-09-10 11:00:34 +0530 |
|---|---|---|
| committer | Sudar <sudar@sudarmuthu.com> | 2014-09-10 11:00:34 +0530 |
| commit | fe00b04a0e1a58f63ae134081d2d896f27ac3f2d (patch) | |
| tree | 632698c837a0828541dde6acb72fd10f6cb1b7ec /examples | |
| parent | e30bb5c28a42152007d70325477f364605b73f34 (diff) | |
| parent | 48356f96ce05948a046d0732dedda66b3e0b69c8 (diff) | |
Merge pull request #254 from peplin/test-suite-and-ci
Add an automated test runner for example programs and Travis CI integration
Diffstat (limited to 'examples')
24 files changed, 9 insertions, 603 deletions
diff --git a/examples/ATtinyBlink/Makefile b/examples/ATtinyBlink/Makefile index a89de1c..b4e49be 100644 --- a/examples/ATtinyBlink/Makefile +++ b/examples/ATtinyBlink/Makefile @@ -1,6 +1,6 @@ # Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile -# if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone. +# if you have placed the alternate core in your sketchbook directory, then you can just mention the core name alone. ALTERNATE_CORE = attiny # If not, you might have to include the full path. #ALTERNATE_CORE_PATH = /home/sudar/Dropbox/code/arduino-sketches/hardware/attiny/ diff --git a/examples/AnalogInOutSerial/AnalogInOutSerial.ino b/examples/AnalogInOutSerial/AnalogInOutSerial.ino deleted file mode 100644 index e142f69..0000000 --- a/examples/AnalogInOutSerial/AnalogInOutSerial.ino +++ /dev/null @@ -1,53 +0,0 @@ -/* - Analog input, analog output, serial output - - Reads an analog input pin, maps the result to a range from 0 to 255 - and uses the result to set the pulsewidth modulation (PWM) of an output pin. - Also prints the results to the serial monitor. - - The circuit: - * potentiometer connected to analog pin 0. - Center pin of the potentiometer goes to the analog pin. - side pins of the potentiometer go to +5V and ground - * LED connected from digital pin 9 to ground - - created 29 Dec. 2008 - modified 30 Aug 2011 - by Tom Igoe - - This example code is in the public domain. - - */ - -// These constants won't change. They're used to give names -// to the pins used: -const int analogInPin = A0; // Analog input pin that the potentiometer is attached to -const int analogOutPin = 9; // Analog output pin that the LED is attached to - -int sensorValue = 0; // value read from the pot -int outputValue = 0; // value output to the PWM (analog out) - -void setup() { - // initialize serial communications at 9600 bps: - Serial.begin(9600); -} - -void loop() { - // read the analog in value: - sensorValue = analogRead(analogInPin); - // map it to the range of the analog out: - outputValue = map(sensorValue, 0, 1023, 0, 255); - // change the analog out value: - analogWrite(analogOutPin, outputValue); - - // print the results to the serial monitor: - Serial.print("sensor = " ); - Serial.print(sensorValue); - Serial.print("\t output = "); - Serial.println(outputValue); - - // wait 10 milliseconds before the next loop - // for the analog-to-digital converter to settle - // after the last reading: - delay(10); -} diff --git a/examples/AnalogInOutSerial/Makefile b/examples/AnalogInOutSerial/Makefile deleted file mode 100644 index 3dea6c0..0000000 --- a/examples/AnalogInOutSerial/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../../Arduino.mk diff --git a/examples/Blink/Blink.ino b/examples/Blink/Blink.ino deleted file mode 100644 index 1953c39..0000000 --- a/examples/Blink/Blink.ino +++ /dev/null @@ -1,19 +0,0 @@ -/* - Blink - Turns on an LED on for one second, then off for one second, repeatedly. - - This example code is in the public domain. - */ - -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 -} diff --git a/examples/Blink/Makefile b/examples/Blink/Makefile deleted file mode 100644 index 7678e9b..0000000 --- a/examples/Blink/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../../Arduino.mk - diff --git a/examples/BlinkChipKIT/BlinkChipKIT.pde b/examples/BlinkChipKIT/BlinkChipKIT.pde deleted file mode 100644 index 1953c39..0000000 --- a/examples/BlinkChipKIT/BlinkChipKIT.pde +++ /dev/null @@ -1,19 +0,0 @@ -/* - Blink - Turns on an LED on for one second, then off for one second, repeatedly. - - This example code is in the public domain. - */ - -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 -} diff --git a/examples/BlinkChipKIT/Makefile b/examples/BlinkChipKIT/Makefile deleted file mode 100644 index 87a9f7d..0000000 --- a/examples/BlinkChipKIT/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -BOARD_TAG = mega_pic32 -ARDUINO_LIBS = - -include ../../chipKIT.mk - diff --git a/examples/BlinkInAVRC/Makefile b/examples/BlinkInAVRC/Makefile deleted file mode 100644 index 04049bb..0000000 --- a/examples/BlinkInAVRC/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# This sample Makefile, explains how you can compile plain AVR C file. -# -# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile - -NO_CORE = Yes - -BOARD_TAG = atmega16 -MCU = atmega16 -F_CPU = 8000000L - -ISP_PROG = stk500v1 -AVRDUDE_ISP_BAUDRATE = 19200 - -include $(ARDMK_DIR)/Arduino.mk - -# !!! Important. You have to use make ispload to upload when using ISP programmer diff --git a/examples/BlinkInAVRC/blink.c b/examples/BlinkInAVRC/blink.c deleted file mode 100644 index d8b7c8f..0000000 --- a/examples/BlinkInAVRC/blink.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * © Anil Kumar Pugalia, 2010. Email: email@sarika-pugs.com - * - * ATmega48/88/168, ATmega16/32 - * - * Example Blink. Toggles all IO pins at 1Hz - */ - -#include <avr/io.h> -#include <util/delay.h> - -void init_io(void) -{ - // 1 = output, 0 = input - DDRB = 0b11111111; // All outputs - DDRC = 0b11111111; // All outputs - DDRD = 0b11111110; // PORTD (RX on PD0). Just for demo -} - -int main(void) -{ - init_io(); - - while (1) - { - PORTC = 0xFF; - PORTB = 0xFF; - PORTD = 0xFF; - _delay_ms(500); - - PORTC = 0x00; - PORTB = 0x00; - PORTD = 0x00; - _delay_ms(500); - } - - return 0; -} diff --git a/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino b/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino deleted file mode 100644 index 0143571..0000000 --- a/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino +++ /dev/null @@ -1,65 +0,0 @@ -/* Blink without Delay - - Turns on and off a light emitting diode(LED) connected to a digital - pin, without using the delay() function. This means that other code - can run at the same time without being interrupted by the LED code. - - The circuit: - * LED attached from pin 13 to ground. - * Note: on most Arduinos, there is already an LED on the board - that's attached to pin 13, so no hardware is needed for this example. - - - created 2005 - by David A. Mellis - modified 8 Feb 2010 - by Paul Stoffregen - - This example code is in the public domain. - - - http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay - */ - -// constants won't change. Used here to -// set pin numbers: -const int ledPin = 13; // the number of the LED pin - -// Variables will change: -int ledState = LOW; // ledState used to set the LED -long previousMillis = 0; // will store last time LED was updated - -// the follow variables is a long because the time, measured in miliseconds, -// will quickly become a bigger number than can be stored in an int. -long interval = 1000; // interval at which to blink (milliseconds) - -void setup() { - // set the digital pin as output: - pinMode(ledPin, OUTPUT); -} - -void loop() -{ - // here is where you'd put code that needs to be running all the time. - - // check to see if it's time to blink the LED; that is, if the - // difference between the current time and last time you blinked - // the LED is bigger than the interval at which you want to - // blink the LED. - unsigned long currentMillis = millis(); - - if(currentMillis - previousMillis > interval) { - // save the last time you blinked the LED - previousMillis = currentMillis; - - // if the LED is off turn it on and vice-versa: - if (ledState == LOW) - ledState = HIGH; - else - ledState = LOW; - - // set the LED with the ledState of the variable: - digitalWrite(ledPin, ledState); - } -} - diff --git a/examples/BlinkWithoutDelay/Makefile b/examples/BlinkWithoutDelay/Makefile deleted file mode 100644 index 3dea6c0..0000000 --- a/examples/BlinkWithoutDelay/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../../Arduino.mk diff --git a/examples/Fade/Fade.ino b/examples/Fade/Fade.ino deleted file mode 100644 index b47bf43..0000000 --- a/examples/Fade/Fade.ino +++ /dev/null @@ -1,31 +0,0 @@ -/* - Fade - - This example shows how to fade an LED on pin 9 - using the analogWrite() function. - - This example code is in the public domain. - - */ -int brightness = 0; // how bright the LED is -int fadeAmount = 5; // how many points to fade the LED by - -void setup() { - // declare pin 9 to be an output: - pinMode(9, OUTPUT); -} - -void loop() { - // set the brightness of pin 9: - analogWrite(9, brightness); - - // change the brightness for next time through the loop: - brightness = brightness + fadeAmount; - - // reverse the direction of the fading at the ends of the fade: - if (brightness == 0 || brightness == 255) { - fadeAmount = -fadeAmount ; - } - // wait for 30 milliseconds to see the dimming effect - delay(30); -} diff --git a/examples/Fade/Makefile b/examples/Fade/Makefile deleted file mode 100644 index 3dea6c0..0000000 --- a/examples/Fade/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../../Arduino.mk diff --git a/examples/HelloWorld/HelloWorld.ino b/examples/HelloWorld/HelloWorld.ino deleted file mode 100644 index e99957d..0000000 --- a/examples/HelloWorld/HelloWorld.ino +++ /dev/null @@ -1,58 +0,0 @@ -/* - LiquidCrystal Library - Hello World - - Demonstrates the use a 16x2 LCD display. The LiquidCrystal - library works with all LCD displays that are compatible with the - Hitachi HD44780 driver. There are many of them out there, and you - can usually tell them by the 16-pin interface. - - This sketch prints "Hello World!" to the LCD - and shows the time. - - The circuit: - * LCD RS pin to digital pin 12 - * LCD Enable pin to digital pin 11 - * LCD D4 pin to digital pin 5 - * LCD D5 pin to digital pin 4 - * LCD D6 pin to digital pin 3 - * LCD D7 pin to digital pin 2 - * LCD R/W pin to ground - * 10K resistor: - * ends to +5V and ground - * wiper to LCD VO pin (pin 3) - - Library originally added 18 Apr 2008 - by David A. Mellis - library modified 5 Jul 2009 - by Limor Fried (http://www.ladyada.net) - example added 9 Jul 2009 - by Tom Igoe - modified 22 Nov 2010 - by Tom Igoe - - This example code is in the public domain. - - http://www.arduino.cc/en/Tutorial/LiquidCrystal - */ - -// include the library code: -#include <LiquidCrystal.h> - -// initialize the library with the numbers of the interface pins -LiquidCrystal lcd(12, 11, 5, 4, 3, 2); - -void setup() { - // set up the LCD's number of columns and rows: - lcd.begin(16, 2); - // Print a message to the LCD. - lcd.print("hello, world!"); -} - -void loop() { - // set the cursor to column 0, line 1 - // (note: line 1 is the second row, since counting begins with 0): - lcd.setCursor(0, 1); - // print the number of seconds since reset: - lcd.print(millis()/1000); -} - diff --git a/examples/HelloWorld/Makefile b/examples/HelloWorld/Makefile deleted file mode 100644 index fb94fdd..0000000 --- a/examples/HelloWorld/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = LiquidCrystal - -include ../../Arduino.mk diff --git a/examples/README.md b/examples/README.md index b170cdc..39425b3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,7 +1,11 @@ -This folder contains the list of example Arduino sketches and makefile showing the different usage patterns +This folder contains the list of example Arduino sketches and makefile showing +the different usage patterns + +- BlinkInAVRC - Shows how to use plain AVR C code +- ATtinyBlink - Shows how to use different cores like ATtiny + +These three examples are a step back, in the "tests" directory. - Blink - Shows normal usage - HelloWorld - Shows how to include Arduino libraries -- BlinkInAVRC - Shows how to use plain AVR C code - BlinkChipKIT - Shows how to use ChipKIT -- ATtinyBlink - Shows how to use different cores like ATtiny diff --git a/examples/TinySoftWareSerial/Makefile b/examples/TinySoftWareSerial/Makefile index 08f918d..991e57e 100644 --- a/examples/TinySoftWareSerial/Makefile +++ b/examples/TinySoftWareSerial/Makefile @@ -9,6 +9,7 @@ BOARD_TAG = attiny85-8 ARDUINO_LIBS = SoftwareSerial +include ../TestSuiteCommon.mk include $(ARDMK_DIR)/Arduino.mk # !!! Important. You have to use make ispload to upload when using ISP programmer diff --git a/examples/WebServer/Makefile b/examples/WebServer/Makefile deleted file mode 100644 index 51b9ac2..0000000 --- a/examples/WebServer/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile - -BOARD_TAG = uno -ARDUINO_LIBS = Ethernet SPI - -include ../../Arduino.mk diff --git a/examples/WebServer/WebServer.ino b/examples/WebServer/WebServer.ino deleted file mode 100644 index fb2a1b9..0000000 --- a/examples/WebServer/WebServer.ino +++ /dev/null @@ -1,82 +0,0 @@ -/* - Web Server - - A simple web server that shows the value of the analog input pins. - using an Arduino Wiznet Ethernet shield. - - Circuit: - * Ethernet shield attached to pins 10, 11, 12, 13 - * Analog inputs attached to pins A0 through A5 (optional) - - created 18 Dec 2009 - by David A. Mellis - modified 4 Sep 2010 - by Tom Igoe - - */ - -#include <SPI.h> -#include <Ethernet.h> - -// Enter a MAC address and IP address for your controller below. -// The IP address will be dependent on your local network: -byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; -IPAddress ip(192,168,1, 178); - -// Initialize the Ethernet server library -// with the IP address and port you want to use -// (port 80 is default for HTTP): -EthernetServer server(80); - -void setup() -{ - // start the Ethernet connection and the server: - Ethernet.begin(mac, ip); - server.begin(); -} - -void loop() -{ - // listen for incoming clients - EthernetClient client = server.available(); - if (client) { - // an http request ends with a blank line - boolean currentLineIsBlank = true; - while (client.connected()) { - if (client.available()) { - char c = client.read(); - // if you've gotten to the end of the line (received a newline - // character) and the line is blank, the http request has ended, - // so you can send a reply - if (c == '\n' && currentLineIsBlank) { - // send a standard http response header - client.println("HTTP/1.1 200 OK"); - client.println("Content-Type: text/html"); - client.println(); - - // output the value of each analog input pin - for (int analogChannel = 0; analogChannel < 6; analogChannel++) { - client.print("analog input "); - client.print(analogChannel); - client.print(" is "); - client.print(analogRead(analogChannel)); - client.println("<br />"); - } - break; - } - if (c == '\n') { - // you're starting a new line - currentLineIsBlank = true; - } - else if (c != '\r') { - // you've gotten a character on the current line - currentLineIsBlank = false; - } - } - } - // give the web browser time to receive the data - delay(1); - // close the connection: - client.stop(); - } -} diff --git a/examples/master_reader/Makefile b/examples/master_reader/Makefile deleted file mode 100644 index 3030deb..0000000 --- a/examples/master_reader/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile - -BOARD_TAG = uno -ARDUINO_LIBS = Wire - -include ../../Arduino.mk diff --git a/examples/master_reader/master_reader.ino b/examples/master_reader/master_reader.ino deleted file mode 100644 index 4124d7d..0000000 --- a/examples/master_reader/master_reader.ino +++ /dev/null @@ -1,32 +0,0 @@ -// Wire Master Reader -// by Nicholas Zambetti <http://www.zambetti.com> - -// Demonstrates use of the Wire library -// Reads data from an I2C/TWI slave device -// Refer to the "Wire Slave Sender" example for use with this - -// Created 29 March 2006 - -// This example code is in the public domain. - - -#include <Wire.h> - -void setup() -{ - Wire.begin(); // join i2c bus (address optional for master) - Serial.begin(9600); // start serial for output -} - -void loop() -{ - Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 - - while(Wire.available()) // slave may send less than requested - { - char c = Wire.read(); // receive a byte as character - Serial.print(c); // print the character - } - - delay(500); -} diff --git a/examples/toneMelody/Makefile b/examples/toneMelody/Makefile deleted file mode 100644 index 3dea6c0..0000000 --- a/examples/toneMelody/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -BOARD_TAG = uno -ARDUINO_LIBS = - -include ../../Arduino.mk diff --git a/examples/toneMelody/pitches.h b/examples/toneMelody/pitches.h deleted file mode 100644 index 55c7d54..0000000 --- a/examples/toneMelody/pitches.h +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************* - * Public Constants - *************************************************/ - -#define NOTE_B0 31 -#define NOTE_C1 33 -#define NOTE_CS1 35 -#define NOTE_D1 37 -#define NOTE_DS1 39 -#define NOTE_E1 41 -#define NOTE_F1 44 -#define NOTE_FS1 46 -#define NOTE_G1 49 -#define NOTE_GS1 52 -#define NOTE_A1 55 -#define NOTE_AS1 58 -#define NOTE_B1 62 -#define NOTE_C2 65 -#define NOTE_CS2 69 -#define NOTE_D2 73 -#define NOTE_DS2 78 -#define NOTE_E2 82 -#define NOTE_F2 87 -#define NOTE_FS2 93 -#define NOTE_G2 98 -#define NOTE_GS2 104 -#define NOTE_A2 110 -#define NOTE_AS2 117 -#define NOTE_B2 123 -#define NOTE_C3 131 -#define NOTE_CS3 139 -#define NOTE_D3 147 -#define NOTE_DS3 156 -#define NOTE_E3 165 -#define NOTE_F3 175 -#define NOTE_FS3 185 -#define NOTE_G3 196 -#define NOTE_GS3 208 -#define NOTE_A3 220 -#define NOTE_AS3 233 -#define NOTE_B3 247 -#define NOTE_C4 262 -#define NOTE_CS4 277 -#define NOTE_D4 294 -#define NOTE_DS4 311 -#define NOTE_E4 330 -#define NOTE_F4 349 -#define NOTE_FS4 370 -#define NOTE_G4 392 -#define NOTE_GS4 415 -#define NOTE_A4 440 -#define NOTE_AS4 466 -#define NOTE_B4 494 -#define NOTE_C5 523 -#define NOTE_CS5 554 -#define NOTE_D5 587 -#define NOTE_DS5 622 -#define NOTE_E5 659 -#define NOTE_F5 698 -#define NOTE_FS5 740 -#define NOTE_G5 784 -#define NOTE_GS5 831 -#define NOTE_A5 880 -#define NOTE_AS5 932 -#define NOTE_B5 988 -#define NOTE_C6 1047 -#define NOTE_CS6 1109 -#define NOTE_D6 1175 -#define NOTE_DS6 1245 -#define NOTE_E6 1319 -#define NOTE_F6 1397 -#define NOTE_FS6 1480 -#define NOTE_G6 1568 -#define NOTE_GS6 1661 -#define NOTE_A6 1760 -#define NOTE_AS6 1865 -#define NOTE_B6 1976 -#define NOTE_C7 2093 -#define NOTE_CS7 2217 -#define NOTE_D7 2349 -#define NOTE_DS7 2489 -#define NOTE_E7 2637 -#define NOTE_F7 2794 -#define NOTE_FS7 2960 -#define NOTE_G7 3136 -#define NOTE_GS7 3322 -#define NOTE_A7 3520 -#define NOTE_AS7 3729 -#define NOTE_B7 3951 -#define NOTE_C8 4186 -#define NOTE_CS8 4435 -#define NOTE_D8 4699 -#define NOTE_DS8 4978 - - diff --git a/examples/toneMelody/toneMelody.ino b/examples/toneMelody/toneMelody.ino deleted file mode 100644 index 8593ab7..0000000 --- a/examples/toneMelody/toneMelody.ino +++ /dev/null @@ -1,49 +0,0 @@ -/* - Melody - - Plays a melody - - circuit: - * 8-ohm speaker on digital pin 8 - - created 21 Jan 2010 - modified 30 Aug 2011 - by Tom Igoe - -This example code is in the public domain. - - http://arduino.cc/en/Tutorial/Tone - - */ - #include "pitches.h" - -// notes in the melody: -int melody[] = { - NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4}; - -// note durations: 4 = quarter note, 8 = eighth note, etc.: -int noteDurations[] = { - 4, 8, 8, 4,4,4,4,4 }; - -void setup() { - // iterate over the notes of the melody: - for (int thisNote = 0; thisNote < 8; thisNote++) { - - // to calculate the note duration, take one second - // divided by the note type. - //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc. - int noteDuration = 1000/noteDurations[thisNote]; - tone(8, melody[thisNote],noteDuration); - - // to distinguish the notes, set a minimum time between them. - // the note's duration + 30% seems to work well: - int pauseBetweenNotes = noteDuration * 1.30; - delay(pauseBetweenNotes); - // stop the tone playing: - noTone(8); - } -} - -void loop() { - // no need to repeat the melody. -} |
