From c86ce093ce93eb8da1136acd1e81973ef0bb54fc Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Tue, 9 Sep 2014 23:09:35 -0400 Subject: Add a script to compile examples as an automated test suite. * Added script/boostrap.sh to download the Arduino IDE and MPIDE (for chipKIT). Tested in Linux, should work in Cygwin and OS X too. * Added script/runtests.sh to run "make" in each example project and collect the results. The script returns -1 if any fails. * Moved currently testable examples to a "tests" directory, separate from examples that require alternative cores. --- .gitignore | 2 + README.md | 7 + examples/ATtinyBlink/Makefile | 2 +- examples/AnalogInOutSerial/AnalogInOutSerial.ino | 53 ------- examples/AnalogInOutSerial/Makefile | 4 - examples/Blink/Blink.ino | 19 --- examples/Blink/Makefile | 5 - examples/BlinkChipKIT/BlinkChipKIT.pde | 19 --- examples/BlinkChipKIT/Makefile | 5 - examples/BlinkInAVRC/Makefile | 16 -- examples/BlinkInAVRC/blink.c | 38 ----- examples/BlinkWithoutDelay/BlinkWithoutDelay.ino | 65 -------- examples/BlinkWithoutDelay/Makefile | 4 - examples/Fade/Fade.ino | 31 ---- examples/Fade/Makefile | 4 - examples/HelloWorld/HelloWorld.ino | 58 ------- examples/HelloWorld/Makefile | 4 - examples/README.md | 10 +- examples/TinySoftWareSerial/Makefile | 1 + examples/WebServer/Makefile | 6 - examples/WebServer/WebServer.ino | 82 ---------- examples/master_reader/Makefile | 6 - examples/master_reader/master_reader.ino | 32 ---- examples/toneMelody/Makefile | 4 - examples/toneMelody/pitches.h | 95 ----------- examples/toneMelody/toneMelody.ino | 49 ------ script/bootstrap.sh | 9 ++ script/bootstrap/arduino.sh | 44 ++++++ script/bootstrap/chipkit.sh | 61 ++++++++ script/bootstrap/common.sh | 191 +++++++++++++++++++++++ script/bootstrap/pip-requirements.txt | 1 + script/runtests.sh | 28 ++++ tests/AnalogInOutSerial/AnalogInOutSerial.ino | 53 +++++++ tests/AnalogInOutSerial/Makefile | 5 + tests/Blink/Blink.ino | 19 +++ tests/Blink/Makefile | 6 + tests/BlinkChipKIT/BlinkChipKIT.pde | 19 +++ tests/BlinkChipKIT/Makefile | 6 + tests/BlinkInAVRC/Makefile | 17 ++ tests/BlinkInAVRC/blink.c | 38 +++++ tests/BlinkWithoutDelay/BlinkWithoutDelay.ino | 65 ++++++++ tests/BlinkWithoutDelay/Makefile | 5 + tests/Fade/Fade.ino | 31 ++++ tests/Fade/Makefile | 5 + tests/HelloWorld/HelloWorld.ino | 58 +++++++ tests/HelloWorld/Makefile | 5 + tests/TestSuiteCommon.mk | 13 ++ tests/WebServer/Makefile | 7 + tests/WebServer/WebServer.ino | 82 ++++++++++ tests/master_reader/Makefile | 7 + tests/master_reader/master_reader.ino | 32 ++++ tests/toneMelody/Makefile | 5 + tests/toneMelody/pitches.h | 95 +++++++++++ tests/toneMelody/toneMelody.ino | 49 ++++++ 54 files changed, 974 insertions(+), 603 deletions(-) delete mode 100644 examples/AnalogInOutSerial/AnalogInOutSerial.ino delete mode 100644 examples/AnalogInOutSerial/Makefile delete mode 100644 examples/Blink/Blink.ino delete mode 100644 examples/Blink/Makefile delete mode 100644 examples/BlinkChipKIT/BlinkChipKIT.pde delete mode 100644 examples/BlinkChipKIT/Makefile delete mode 100644 examples/BlinkInAVRC/Makefile delete mode 100644 examples/BlinkInAVRC/blink.c delete mode 100644 examples/BlinkWithoutDelay/BlinkWithoutDelay.ino delete mode 100644 examples/BlinkWithoutDelay/Makefile delete mode 100644 examples/Fade/Fade.ino delete mode 100644 examples/Fade/Makefile delete mode 100644 examples/HelloWorld/HelloWorld.ino delete mode 100644 examples/HelloWorld/Makefile delete mode 100644 examples/WebServer/Makefile delete mode 100644 examples/WebServer/WebServer.ino delete mode 100644 examples/master_reader/Makefile delete mode 100644 examples/master_reader/master_reader.ino delete mode 100644 examples/toneMelody/Makefile delete mode 100644 examples/toneMelody/pitches.h delete mode 100644 examples/toneMelody/toneMelody.ino create mode 100755 script/bootstrap.sh create mode 100644 script/bootstrap/arduino.sh create mode 100644 script/bootstrap/chipkit.sh create mode 100644 script/bootstrap/common.sh create mode 100644 script/bootstrap/pip-requirements.txt create mode 100755 script/runtests.sh create mode 100644 tests/AnalogInOutSerial/AnalogInOutSerial.ino create mode 100644 tests/AnalogInOutSerial/Makefile create mode 100644 tests/Blink/Blink.ino create mode 100644 tests/Blink/Makefile create mode 100644 tests/BlinkChipKIT/BlinkChipKIT.pde create mode 100644 tests/BlinkChipKIT/Makefile create mode 100644 tests/BlinkInAVRC/Makefile create mode 100644 tests/BlinkInAVRC/blink.c create mode 100644 tests/BlinkWithoutDelay/BlinkWithoutDelay.ino create mode 100644 tests/BlinkWithoutDelay/Makefile create mode 100644 tests/Fade/Fade.ino create mode 100644 tests/Fade/Makefile create mode 100644 tests/HelloWorld/HelloWorld.ino create mode 100644 tests/HelloWorld/Makefile create mode 100644 tests/TestSuiteCommon.mk create mode 100644 tests/WebServer/Makefile create mode 100644 tests/WebServer/WebServer.ino create mode 100644 tests/master_reader/Makefile create mode 100644 tests/master_reader/master_reader.ino create mode 100644 tests/toneMelody/Makefile create mode 100644 tests/toneMelody/pitches.h create mode 100644 tests/toneMelody/toneMelody.ino diff --git a/.gitignore b/.gitignore index 06cff06..a0d6d59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.o build-cli /.project +/dependencies +build-* diff --git a/README.md b/README.md index 50785b0..5b24604 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,13 @@ Then, the following line must be added to the project Makefile : $(CXX_NAME) -c -include Arduino.h -x c++ $(CXXFLAGS) $(CPPFLAGS) -fsyntax-only $(CHK_SOURCES) ``` +## Test Suite + +This project includes a suite of example Makefiles and small Arduino and chipKIT +programs to assist the developers. Run `script/bootstrap.sh` to attempt to +automatically install the dependencies (Arduino IDE, MPIDE, etc.). Run +`script/runtests.sh` to attempt to compile all of the examples. + ### Bare-Arduino–Project If you are planning on using this makefile in a larger/professional project, you might want to take a look at the [Bare-Arduino–Project](https://github.com/WeAreLeka/Bare-Arduino-Project) framework. 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 -#include - -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 - -// 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 -#include - -// 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("
"); - } - 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 - -// 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 - -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. -} diff --git a/script/bootstrap.sh b/script/bootstrap.sh new file mode 100755 index 0000000..083bf5d --- /dev/null +++ b/script/bootstrap.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +pushd $SCRIPTS_DIR/.. + +source $SCRIPTS_DIR/bootstrap/chipkit.sh +source $SCRIPTS_DIR/bootstrap/arduino.sh diff --git a/script/bootstrap/arduino.sh b/script/bootstrap/arduino.sh new file mode 100644 index 0000000..3c7e9d7 --- /dev/null +++ b/script/bootstrap/arduino.sh @@ -0,0 +1,44 @@ +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $BOOTSTRAP_DIR/common.sh + +echo "Installing dependencies for building for the Arduino" + +if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then + + echo "Installing Arduino..." + + ARDUINO_BASENAME="arduino-1.0.5" + if [ $OS == "cygwin" ]; then + ARDUINO_FILE="$ARDUINO_BASENAME-r2-windows".zip + EXTRACT_COMMAND="unzip -q" + elif [ $OS == "mac" ]; then + ARDUINO_FILE="$ARDUINO_BASENAME-macosx".zip + EXTRACT_COMMAND="unzip -q" + else + ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tgz + EXTRACT_COMMAND="tar -xzf" + fi + + ARDUINO_URL=http://arduino.googlecode.com/files/$ARDUINO_FILE + + _pushd $DEPENDENCIES_FOLDER + if ! test -e $ARDUINO_FILE + then + echo "Downloading Arduino IDE..." + download $ARDUINO_URL $ARDUINO_FILE + fi + + if ! test -d $ARDUINO_BASENAME + then + echo "Installing Arduino to local folder..." + $EXTRACT_COMMAND $ARDUINO_FILE + echo "Arduino installed" + fi + + _popd + +fi + +echo +echo "${bldgreen}Arduino dependencies installed.$txtrst" diff --git a/script/bootstrap/chipkit.sh b/script/bootstrap/chipkit.sh new file mode 100644 index 0000000..efe9615 --- /dev/null +++ b/script/bootstrap/chipkit.sh @@ -0,0 +1,61 @@ +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $BOOTSTRAP_DIR/common.sh + +echo "Installing dependencies for building for the chipKIT" + + +if [ -z "$MPIDE_DIR" ] || ! test -e $MPIDE_DIR || [ $OS == "cygwin" ]; then + + echo "Installing MPIDE..." + + if [ $OS == "cygwin" ]; then + MPIDE_BASENAME="mpide-0023-windows-20130715" + MPIDE_FILE="$MPIDE_BASENAME".zip + EXTRACT_COMMAND="unzip -q" + if ! command -v unzip >/dev/null 2>&1; then + _cygwin_error "unzip" + fi + elif [ $OS == "mac" ]; then + MPIDE_BASENAME=mpide-0023-macosx-20130715 + MPIDE_FILE="$MPIDE_BASENAME".dmg + else + MPIDE_BASENAME=mpide-0023-linux64-20130817-test + MPIDE_FILE="$MPIDE_BASENAME".tgz + EXTRACT_COMMAND="tar -xzf" + fi + + MPIDE_URL=http://chipkit.s3.amazonaws.com/builds/$MPIDE_FILE + + _pushd $DEPENDENCIES_FOLDER + if ! test -e $MPIDE_FILE + then + echo "Downloading MPIDE..." + download $MPIDE_URL $MPIDE_FILE + fi + + if ! test -d $MPIDE_BASENAME + then + echo "Installing MPIDE to local folder..." + if [ $OS == "mac" ]; then + hdiutil attach $MPIDE_FILE + cp -R /Volumes/Mpide/Mpide.app/Contents/Resources/Java $MPIDE_BASENAME + hdiutil detach /Volumes/Mpide + else + $EXTRACT_COMMAND $MPIDE_FILE + fi + echo "MPIDE installed" + fi + + if [ $OS == "cygwin" ]; then + chmod a+x mpide/hardware/pic32/compiler/pic32-tools/bin/* + chmod a+x -R mpide/hardware/pic32/compiler/pic32-tools/pic32mx/ + chmod a+x mpide/*.dll + chmod a+x mpide/hardware/tools/avr/bin/* + fi + _popd + +fi + +echo +echo "${bldgreen}chipKIT dependencies installed.$txtrst" diff --git a/script/bootstrap/common.sh b/script/bootstrap/common.sh new file mode 100644 index 0000000..695d6b7 --- /dev/null +++ b/script/bootstrap/common.sh @@ -0,0 +1,191 @@ +#!/usr/bin/env bash + +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +if [ -z $COMMON_SOURCED ]; then + + # TODO this is kind of a hacky way of determining if root is required - + # ideally we wouuld set up a little virtualenv in the dependencies folder + SUDO_CMD= + if command -v sudo >/dev/null 2>&1; then + SUDO_CMD="sudo -E" + + if [ -z $CI ] && [ -z $VAGRANT ]; then + echo "The bootstrap script needs to install a few packages to your system as an admin, and we will use the 'sudo' command - enter your password to continue" + $SUDO_CMD ls > /dev/null + fi + fi + + KERNEL=`uname` + ARCH=`uname -m` + if [ ${KERNEL:0:7} == "MINGW32" ]; then + OS="windows" + elif [ ${KERNEL:0:6} == "CYGWIN" ]; then + OS="cygwin" + elif [ $KERNEL == "Darwin" ]; then + OS="mac" + else + OS="linux" + if ! command -v lsb_release >/dev/null 2>&1; then + # Arch Linux + if command -v pacman>/dev/null 2>&1; then + $SUDO_CMD pacman -S lsb-release + fi + fi + + DISTRO=`lsb_release -si` + fi + + + die() { + echo >&2 "${bldred}$@${txtrst}" + exit 1 + } + + _cygwin_error() { + echo + echo "${bldred}Missing \"$1\"${txtrst} - run the Cygwin installer again and select the base package set:" + echo " $CYGWIN_PACKAGES" + echo "After installing the packages, re-run this bootstrap script." + die + } + + if ! command -v tput >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + echo "OPTIONAL: Install the \"ncurses\" package in Cygwin to get colored shell output" + fi + else + set +e + # These exit with 1 when provisioning in a Vagrant box...? + txtrst=$(tput sgr0) # reset + bldred=${txtbld}$(tput setaf 1) + bldgreen=${txtbld}$(tput setaf 2) + set -e + fi + + + _pushd() { + pushd $1 > /dev/null + } + + _popd() { + popd > /dev/null + } + + _wait() { + if [ -z $CI ] && [ -z $VAGRANT ]; then + echo "Press Enter when done" + read + fi + } + + _install() { + if [ $OS == "cygwin" ]; then + _cygwin_error $1 + elif [ $OS == "mac" ]; then + # brew exists with 1 if it's already installed + set +e + brew install $1 + set -e + else + if [ -z $DISTRO ]; then + echo + echo "Missing $1 - install it using your distro's package manager or build from source" + _wait + else + if [ $DISTRO == "arch" ]; then + $SUDO_CMD pacman -S $1 + elif [ $DISTRO == "Ubuntu" ]; then + $SUDO_CMD apt-get update -qq + $SUDO_CMD apt-get install $1 -y + else + echo + echo "Missing $1 - install it using your distro's package manager or build from source" + _wait + fi + fi + fi + } + + download() { + url=$1 + filename=$2 + curl $url -L -o $filename + } + + if [ `id -u` == 0 ]; then + die "Error: running as root - don't use 'sudo' with this script" + fi + + if ! command -v unzip >/dev/null 2>&1; then + _install "unzip" + fi + + if ! command -v curl >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + _cygwin_error "curl" + else + _install curl + fi + fi + + echo "Storing all downloaded dependencies in the \"dependencies\" folder" + + DEPENDENCIES_FOLDER="dependencies" + mkdir -p $DEPENDENCIES_FOLDER + + if ! command -v make >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + _cygwin_error "make" + elif [ $OS == "mac" ]; then + die "Missing 'make' - install the Xcode CLI tools" + else + if [ $DISTRO == "arch" ]; then + _install "base-devel" + elif [ $DISTRO == "Ubuntu" ]; then + _install "build-essential" + fi + fi + fi + + if [ $DISTRO == "Ubuntu" ] && [ $ARCH == "x86_64" ]; then + _install "libc6-i386" + _install "lib32gcc1" + fi + + if ! command -v g++ >/dev/null 2>&1; then + if [ $DISTRO == "Ubuntu" ]; then + _install "g++" + fi + fi + + if ! command -v python >/dev/null 2>&1; then + echo "Installing Python..." + _install "python" + fi + + if ! command -v pip >/dev/null 2>&1; then + echo "Installing Pip..." + if ! command -v easy_install >/dev/null 2>&1; then + _install "python-setuptools" + fi + + if ! command -v easy_install >/dev/null 2>&1; then + die "easy_install not available, can't install pip" + fi + + $SUDO_CMD easy_install pip + fi + + PIP_SUDO_CMD= + if [ -z $VIRTUAL_ENV ]; then + # Only use sudo if the user doesn't have an active virtualenv + PIP_SUDO_CMD=$SUDO_CMD + fi + + $PIP_SUDO_CMD pip install --upgrade setuptools + $PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt + + COMMON_SOURCED=1 +fi diff --git a/script/bootstrap/pip-requirements.txt b/script/bootstrap/pip-requirements.txt new file mode 100644 index 0000000..8313187 --- /dev/null +++ b/script/bootstrap/pip-requirements.txt @@ -0,0 +1 @@ +pyserial==2.7 diff --git a/script/runtests.sh b/script/runtests.sh new file mode 100755 index 0000000..ad42f74 --- /dev/null +++ b/script/runtests.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +failures=() + +for dir in tests/*/ +do + dir=${dir%*/} + example=${dir##*/} + pushd $dir + echo "Compiling $example..." + make_output=`make clean` + make_output=`make` + if [[ $? -ne 0 ]]; then + failures+=("$example") + echo "Example $example failed" + fi + popd +done + +for failure in "${failures[@]}"; do + echo "Example $failure failed" +done + +if [[ ${#failures[@]} -eq 0 ]]; then + echo "All tests passed." +else + exit 1 +fi diff --git a/tests/AnalogInOutSerial/AnalogInOutSerial.ino b/tests/AnalogInOutSerial/AnalogInOutSerial.ino new file mode 100644 index 0000000..e142f69 --- /dev/null +++ b/tests/AnalogInOutSerial/AnalogInOutSerial.ino @@ -0,0 +1,53 @@ +/* + 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/tests/AnalogInOutSerial/Makefile b/tests/AnalogInOutSerial/Makefile new file mode 100644 index 0000000..872d069 --- /dev/null +++ b/tests/AnalogInOutSerial/Makefile @@ -0,0 +1,5 @@ +BOARD_TAG = uno +ARDUINO_LIBS = + +include ../TestSuiteCommon.mk +include ../../Arduino.mk diff --git a/tests/Blink/Blink.ino b/tests/Blink/Blink.ino new file mode 100644 index 0000000..1953c39 --- /dev/null +++ b/tests/Blink/Blink.ino @@ -0,0 +1,19 @@ +/* + 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/tests/Blink/Makefile b/tests/Blink/Makefile new file mode 100644 index 0000000..d41effa --- /dev/null +++ b/tests/Blink/Makefile @@ -0,0 +1,6 @@ +BOARD_TAG = uno +ARDUINO_LIBS = + +include ../TestSuiteCommon.mk +include ../../Arduino.mk + diff --git a/tests/BlinkChipKIT/BlinkChipKIT.pde b/tests/BlinkChipKIT/BlinkChipKIT.pde new file mode 100644 index 0000000..1953c39 --- /dev/null +++ b/tests/BlinkChipKIT/BlinkChipKIT.pde @@ -0,0 +1,19 @@ +/* + 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/tests/BlinkChipKIT/Makefile b/tests/BlinkChipKIT/Makefile new file mode 100644 index 0000000..bec2794 --- /dev/null +++ b/tests/BlinkChipKIT/Makefile @@ -0,0 +1,6 @@ +BOARD_TAG = mega_pic32 +ARDUINO_LIBS = + +include ../TestSuiteCommon.mk +include ../../chipKIT.mk + diff --git a/tests/BlinkInAVRC/Makefile b/tests/BlinkInAVRC/Makefile new file mode 100644 index 0000000..9080b24 --- /dev/null +++ b/tests/BlinkInAVRC/Makefile @@ -0,0 +1,17 @@ +# 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 ../TestSuiteCommon.mk +include $(ARDMK_DIR)/Arduino.mk + +# !!! Important. You have to use make ispload to upload when using ISP programmer diff --git a/tests/BlinkInAVRC/blink.c b/tests/BlinkInAVRC/blink.c new file mode 100644 index 0000000..d8b7c8f --- /dev/null +++ b/tests/BlinkInAVRC/blink.c @@ -0,0 +1,38 @@ +/* + * © Anil Kumar Pugalia, 2010. Email: email@sarika-pugs.com + * + * ATmega48/88/168, ATmega16/32 + * + * Example Blink. Toggles all IO pins at 1Hz + */ + +#include +#include + +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/tests/BlinkWithoutDelay/BlinkWithoutDelay.ino b/tests/BlinkWithoutDelay/BlinkWithoutDelay.ino new file mode 100644 index 0000000..0143571 --- /dev/null +++ b/tests/BlinkWithoutDelay/BlinkWithoutDelay.ino @@ -0,0 +1,65 @@ +/* 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/tests/BlinkWithoutDelay/Makefile b/tests/BlinkWithoutDelay/Makefile new file mode 100644 index 0000000..872d069 --- /dev/null +++ b/tests/BlinkWithoutDelay/Makefile @@ -0,0 +1,5 @@ +BOARD_TAG = uno +ARDUINO_LIBS = + +include ../TestSuiteCommon.mk +include ../../Arduino.mk diff --git a/tests/Fade/Fade.ino b/tests/Fade/Fade.ino new file mode 100644 index 0000000..b47bf43 --- /dev/null +++ b/tests/Fade/Fade.ino @@ -0,0 +1,31 @@ +/* + 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/tests/Fade/Makefile b/tests/Fade/Makefile new file mode 100644 index 0000000..872d069 --- /dev/null +++ b/tests/Fade/Makefile @@ -0,0 +1,5 @@ +BOARD_TAG = uno +ARDUINO_LIBS = + +include ../TestSuiteCommon.mk +include ../../Arduino.mk diff --git a/tests/HelloWorld/HelloWorld.ino b/tests/HelloWorld/HelloWorld.ino new file mode 100644 index 0000000..e99957d --- /dev/null +++ b/tests/HelloWorld/HelloWorld.ino @@ -0,0 +1,58 @@ +/* + 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 + +// 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/tests/HelloWorld/Makefile b/tests/HelloWorld/Makefile new file mode 100644 index 0000000..0af2ed4 --- /dev/null +++ b/tests/HelloWorld/Makefile @@ -0,0 +1,5 @@ +BOARD_TAG = uno +ARDUINO_LIBS = LiquidCrystal + +include ../TestSuiteCommon.mk +include ../../Arduino.mk diff --git a/tests/TestSuiteCommon.mk b/tests/TestSuiteCommon.mk new file mode 100644 index 0000000..5fa4f50 --- /dev/null +++ b/tests/TestSuiteCommon.mk @@ -0,0 +1,13 @@ +ARDMK_DIR=../../ +DEPENDENCIES_FOLDER = ../../dependencies +DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_FOLDER)/mpide-0023-linux64-20130817-test + +ifeq ($(MPIDE_DIR),) + MPIDE_DIR = $(DEPENDENCIES_MPIDE_DIR) +endif + +DEPENDENCIES_ARDUINO_DIR = $(DEPENDENCIES_FOLDER)/arduino-1.0.5 + +ifeq ($(ARDUINO_DIR),) + ARDUINO_DIR = $(DEPENDENCIES_ARDUINO_DIR) +endif diff --git a/tests/WebServer/Makefile b/tests/WebServer/Makefile new file mode 100644 index 0000000..5fbefae --- /dev/null +++ b/tests/WebServer/Makefile @@ -0,0 +1,7 @@ +# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile + +BOARD_TAG = uno +ARDUINO_LIBS = Ethernet SPI + +include ../TestSuiteCommon.mk +include ../../Arduino.mk diff --git a/tests/WebServer/WebServer.ino b/tests/WebServer/WebServer.ino new file mode 100644 index 0000000..fb2a1b9 --- /dev/null +++ b/tests/WebServer/WebServer.ino @@ -0,0 +1,82 @@ +/* + 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 +#include + +// 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("
"); + } + 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/tests/master_reader/Makefile b/tests/master_reader/Makefile new file mode 100644 index 0000000..8a42a8e --- /dev/null +++ b/tests/master_reader/Makefile @@ -0,0 +1,7 @@ +# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile + +BOARD_TAG = uno +ARDUINO_LIBS = Wire + +include ../TestSuiteCommon.mk +include ../../Arduino.mk diff --git a/tests/master_reader/master_reader.ino b/tests/master_reader/master_reader.ino new file mode 100644 index 0000000..4124d7d --- /dev/null +++ b/tests/master_reader/master_reader.ino @@ -0,0 +1,32 @@ +// Wire Master Reader +// by Nicholas Zambetti + +// 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 + +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/tests/toneMelody/Makefile b/tests/toneMelody/Makefile new file mode 100644 index 0000000..872d069 --- /dev/null +++ b/tests/toneMelody/Makefile @@ -0,0 +1,5 @@ +BOARD_TAG = uno +ARDUINO_LIBS = + +include ../TestSuiteCommon.mk +include ../../Arduino.mk diff --git a/tests/toneMelody/pitches.h b/tests/toneMelody/pitches.h new file mode 100644 index 0000000..55c7d54 --- /dev/null +++ b/tests/toneMelody/pitches.h @@ -0,0 +1,95 @@ +/************************************************* + * 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/tests/toneMelody/toneMelody.ino b/tests/toneMelody/toneMelody.ino new file mode 100644 index 0000000..8593ab7 --- /dev/null +++ b/tests/toneMelody/toneMelody.ino @@ -0,0 +1,49 @@ +/* + 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. +} -- cgit v1.2.3