diff --git a/STM32F1/cores/maple/boards.h b/STM32F1/cores/maple/boards.h index 5dc90cd..403250e 100644 --- a/STM32F1/cores/maple/boards.h +++ b/STM32F1/cores/maple/boards.h @@ -76,7 +76,7 @@ extern const uint8 boardADCPins[]; * @brief Pins which are connected to external hardware. * * For example, on Maple boards, it always at least includes - * BOARD_LED_PIN. Its length is BOARD_NR_USED_PINS. + * PB1 for the LED. Its length is BOARD_NR_USED_PINS. */ extern const uint8 boardUsedPins[]; diff --git a/STM32F1/cores/maple/io.h b/STM32F1/cores/maple/io.h index 4adb2c5..ce54461 100644 --- a/STM32F1/cores/maple/io.h +++ b/STM32F1/cores/maple/io.h @@ -143,68 +143,7 @@ uint32 digitalRead(uint8 pin); * @see pinMode() */ uint16 analogRead(uint8 pin); -#if FALSE -// Roger Clark. Deprecated these functions as they are not part of the standard Arduino API -/** - * Toggles the digital value at the given pin. - * - * The pin must have its mode set to OUTPUT. - * - * @param pin the pin to toggle. If the pin is HIGH, set it LOW. If - * it is LOW, set it HIGH. - * - * @see pinMode() - */ -void togglePin(uint8 pin); - -/** - * Toggle the LED. - * - * If the LED is on, turn it off. If it is off, turn it on. - * - * The LED must its mode set to OUTPUT. This can be accomplished - * portably over all LeafLabs boards by calling pinMode(BOARD_LED_PIN, - * OUTPUT) before calling this function. - * - * @see pinMode() - */ -static inline void toggleLED() { - togglePin(BOARD_LED_PIN); -} - -/** - * If the button is currently pressed, waits until the button is no - * longer being pressed, and returns true. Otherwise, returns false. - * - * The button pin must have its mode set to INPUT. This can be - * accomplished portably over all LeafLabs boards by calling - * pinMode(BOARD_BUTTON_PIN, INPUT). - * - * @see pinMode() - */ -uint8 isButtonPressed(uint8 pin=BOARD_BUTTON_PIN, - uint32 pressedLevel=BOARD_BUTTON_PRESSED_LEVEL); - -/** - * Wait until the button is pressed and released, timing out if no - * press occurs. - * - * The button pin must have its mode set to INPUT. This can be - * accomplished portably over all LeafLabs boards by calling - * pinMode(BOARD_BUTTON_PIN, INPUT). - * - * @param timeout_millis Number of milliseconds to wait until the - * button is pressed. If timeout_millis is left out (or 0), wait - * forever. - * - * @return true, if the button was pressed; false, if the timeout was - * reached. - * - * @see pinMode() - */ -uint8 waitForButtonPress(uint32 timeout_millis=0); -#endif /** * Shift out a byte of data, one bit at a time. * diff --git a/STM32F1/libraries/Untested/RTClock/examples/Test_RTClock/Test_RTClock.ino b/STM32F1/libraries/Untested/RTClock/examples/Test_RTClock/Test_RTClock.ino index 773960c..3f0c661 100644 --- a/STM32F1/libraries/Untested/RTClock/examples/Test_RTClock/Test_RTClock.ino +++ b/STM32F1/libraries/Untested/RTClock/examples/Test_RTClock/Test_RTClock.ino @@ -11,7 +11,7 @@ void blink () { } void setup() { -pinMode(BOARD_LED_PIN, OUTPUT); +pinMode(PB1, OUTPUT);// Roger Clark. Updated for removal of LED pin as a global define (PB1 is Maple mini LED Pin) rt.attachSecondsInterrupt(blink); } diff --git a/STM32F1/variants/generic_stm32f103c/board.cpp b/STM32F1/variants/generic_stm32f103c/board.cpp index 6ed9a0c..1c6a570 100644 --- a/STM32F1/variants/generic_stm32f103c/board.cpp +++ b/STM32F1/variants/generic_stm32f103c/board.cpp @@ -107,5 +107,5 @@ extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = { // NOte. These definitions are not really used for generic boards, they only relate to boards modified to behave like Maple boards extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { - BOARD_LED_PIN, BOARD_BUTTON_PIN, USB_DP, USB_DM + USB_DP, USB_DM }; diff --git a/STM32F1/variants/generic_stm32f103c/board/board.h b/STM32F1/variants/generic_stm32f103c/board/board.h index c18af8d..07e2424 100644 --- a/STM32F1/variants/generic_stm32f103c/board/board.h +++ b/STM32F1/variants/generic_stm32f103c/board/board.h @@ -39,9 +39,6 @@ #define CYCLES_PER_MICROSECOND 72 #define SYSTICK_RELOAD_VAL 71999 /* takes a cycle to reload */ -#define BOARD_BUTTON_PIN 32 -#define BOARD_LED_PIN 33 - #define BOARD_NR_USARTS 3 #define BOARD_USART1_TX_PIN PA9 #define BOARD_USART1_RX_PIN PA10 diff --git a/STM32F1/variants/generic_stm32f103rxx/board.cpp b/STM32F1/variants/generic_stm32f103rxx/board.cpp index fe6b16d..9825d9c 100644 --- a/STM32F1/variants/generic_stm32f103rxx/board.cpp +++ b/STM32F1/variants/generic_stm32f103rxx/board.cpp @@ -145,6 +145,6 @@ extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = { /* not sure what this us used for */ extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { - BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN, + BOARD_JTMS_SWDIO_PIN, BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN }; diff --git a/STM32F1/variants/generic_stm32f103rxx/board/board.h b/STM32F1/variants/generic_stm32f103rxx/board/board.h index 0d6a31b..78331ea 100644 --- a/STM32F1/variants/generic_stm32f103rxx/board/board.h +++ b/STM32F1/variants/generic_stm32f103rxx/board/board.h @@ -41,9 +41,6 @@ #define CYCLES_PER_MICROSECOND 72 #define SYSTICK_RELOAD_VAL 71999 /* takes a cycle to reload */ -#define BOARD_BUTTON_PIN 38 -#define BOARD_LED_PIN 13 - // USARTS #define BOARD_NR_USARTS 5 #define BOARD_USART1_TX_PIN PA9 diff --git a/STM32F1/variants/generic_stm32f103zxx/board.cpp b/STM32F1/variants/generic_stm32f103zxx/board.cpp index 66791cd..d575fcb 100644 --- a/STM32F1/variants/generic_stm32f103zxx/board.cpp +++ b/STM32F1/variants/generic_stm32f103zxx/board.cpp @@ -210,6 +210,6 @@ extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = { /* not sure what this us used for */ extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { - BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN, + BOARD_JTMS_SWDIO_PIN, BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN }; diff --git a/STM32F1/variants/generic_stm32f103zxx/board/board.h b/STM32F1/variants/generic_stm32f103zxx/board/board.h index 9d9401c..73cf89d 100644 --- a/STM32F1/variants/generic_stm32f103zxx/board/board.h +++ b/STM32F1/variants/generic_stm32f103zxx/board/board.h @@ -41,9 +41,6 @@ #define CYCLES_PER_MICROSECOND 72 #define SYSTICK_RELOAD_VAL 71999 /* takes a cycle to reload */ -#define BOARD_BUTTON_PIN 38 -#define BOARD_LED_PIN 13 - // USARTS #define BOARD_NR_USARTS 5 #define BOARD_USART1_TX_PIN PA9 diff --git a/STM32F1/variants/maple/board.cpp b/STM32F1/variants/maple/board.cpp index d09694f..e66da96 100644 --- a/STM32F1/variants/maple/board.cpp +++ b/STM32F1/variants/maple/board.cpp @@ -138,6 +138,6 @@ extern const uint8 boardADCPins[] __FLASH__ = { // the button and the LED, it's usually best to leave these pins alone // unless you know what you're doing. extern const uint8 boardUsedPins[] __FLASH__ = { - BOARD_LED_PIN, BOARD_BUTTON_PIN, BOARD_JTMS_SWDIO_PIN, + 13, 33, BOARD_JTMS_SWDIO_PIN, BOARD_JTCK_SWCLK_PIN, BOARD_JTDI_PIN, BOARD_JTDO_PIN, BOARD_NJTRST_PIN }; diff --git a/STM32F1/variants/maple/board/board.h b/STM32F1/variants/maple/board/board.h index e675806..caebcc7 100644 --- a/STM32F1/variants/maple/board/board.h +++ b/STM32F1/variants/maple/board/board.h @@ -36,11 +36,12 @@ /* 72 MHz -> 72 cycles per microsecond. */ #define CYCLES_PER_MICROSECOND 72 -/* Pin number for the built-in button. */ -#define BOARD_BUTTON_PIN 38 +/* Roger clark + +Removed led pin and button pin defines as these are not Arduino API defines +On the Maple the led is on pin 13 and the button is on pin 38 +*/ -/* Pin number for the built-in LED. */ -#define BOARD_LED_PIN 13 /* Number of USARTs/UARTs whose pins are broken out to headers. */ #define BOARD_NR_USARTS 3 @@ -78,7 +79,7 @@ #define BOARD_NR_ADC_PINS 15 /* Number of pins already connected to external hardware. For Maple, - * these are just BOARD_LED_PIN, BOARD_BUTTON_PIN, and the debug port + * these are just led pin , button , and the debug port * pins (see below). */ #define BOARD_NR_USED_PINS 7 diff --git a/STM32F1/variants/maple_mini/board.cpp b/STM32F1/variants/maple_mini/board.cpp index 90ebd3b..358f89c 100644 --- a/STM32F1/variants/maple_mini/board.cpp +++ b/STM32F1/variants/maple_mini/board.cpp @@ -101,5 +101,5 @@ extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = { #define USB_DM 24 extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { - BOARD_LED_PIN, BOARD_BUTTON_PIN, USB_DP, USB_DM + 32, 32, USB_DP, USB_DM }; diff --git a/STM32F1/variants/maple_mini/board/board.h b/STM32F1/variants/maple_mini/board/board.h index ac2e5e5..f8d9daf 100644 --- a/STM32F1/variants/maple_mini/board/board.h +++ b/STM32F1/variants/maple_mini/board/board.h @@ -39,9 +39,6 @@ #define CYCLES_PER_MICROSECOND 72 #define SYSTICK_RELOAD_VAL 71999 /* takes a cycle to reload */ -#define BOARD_BUTTON_PIN 32 -#define BOARD_LED_PIN 33 - #define BOARD_NR_USARTS 3 #define BOARD_USART1_TX_PIN 26 #define BOARD_USART1_RX_PIN 25 diff --git a/STM32F1/variants/microduino/board.cpp b/STM32F1/variants/microduino/board.cpp index f8b2c12..d9434ae 100644 --- a/STM32F1/variants/microduino/board.cpp +++ b/STM32F1/variants/microduino/board.cpp @@ -93,5 +93,5 @@ extern const uint8 boardADCPins[BOARD_NR_ADC_PINS] __FLASH__ = { #define USB_DM 23 extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { - BOARD_LED_PIN, BOARD_BUTTON_PIN, USB_DP, USB_DM + 4, 24, USB_DP, USB_DM }; diff --git a/STM32F1/variants/microduino/board/board.h b/STM32F1/variants/microduino/board/board.h index 49092b5..f6a8778 100644 --- a/STM32F1/variants/microduino/board/board.h +++ b/STM32F1/variants/microduino/board/board.h @@ -40,8 +40,10 @@ #define CYCLES_PER_MICROSECOND 72 #define SYSTICK_RELOAD_VAL 71999 /* takes a cycle to reload */ -#define BOARD_BUTTON_PIN 24 -#define BOARD_LED_PIN 4 +/* Roger Clark. + +Removed the definitions for led pin 4 and button pin 24 +*/ #define BOARD_NR_USARTS 3 #define BOARD_USART1_TX_PIN 1 diff --git a/STM32F1/variants/nucleo_f103rb/board.cpp b/STM32F1/variants/nucleo_f103rb/board.cpp index daf0ccf..d1055f5 100644 --- a/STM32F1/variants/nucleo_f103rb/board.cpp +++ b/STM32F1/variants/nucleo_f103rb/board.cpp @@ -152,5 +152,5 @@ extern const uint8 boardADCPins[] __FLASH__ = { // the button and the LED, it's usually best to leave these pins alone // unless you know what you're doing. extern const uint8 boardUsedPins[] __FLASH__ = { - BOARD_LED_PIN, BOARD_BUTTON_PIN + 13, 27 }; diff --git a/STM32F1/variants/nucleo_f103rb/board/board.h b/STM32F1/variants/nucleo_f103rb/board/board.h index 645bc69..6eafd38 100644 --- a/STM32F1/variants/nucleo_f103rb/board/board.h +++ b/STM32F1/variants/nucleo_f103rb/board/board.h @@ -39,11 +39,13 @@ */ #define CYCLES_PER_MICROSECOND 72 #define SYSTICK_RELOAD_VAL 71999 /* takes a cycle to reload */ -/* Pin number for the built-in button. */ -#define BOARD_BUTTON_PIN 27 -/* Pin number for the built-in LED. */ -#define BOARD_LED_PIN 13 +/* Roger clark. Removed defines for LED pin and Button pin as they are not Arduino API defines */ +// Pin number for the built-in button +//BOARD _ BUTTON _ PIN 27 + +// Pin number for the built-in LED. +//BOARD _ LED _ PIN 13 /* Number of USARTs/UARTs whose pins are broken out to headers. */ #define BOARD_NR_USARTS 3 @@ -81,7 +83,7 @@ #define BOARD_NR_ADC_PINS 6 /* Number of pins already connected to external hardware. For Maple, - * these are just BOARD_LED_PIN, BOARD_BUTTON_PIN, and the debug port + * these are just the debug port * pins (see below). */ #define BOARD_NR_USED_PINS 2 diff --git a/examples/Analog/AnalogInput/AnalogInput.ino b/examples/Analog/AnalogInput/AnalogInput.ino index 9dc3ebf..6146d09 100644 --- a/examples/Analog/AnalogInput/AnalogInput.ino +++ b/examples/Analog/AnalogInput/AnalogInput.ino @@ -22,21 +22,21 @@ int sensorValue = 0; // Variable to store the value coming from the sensor void setup() { // Declare the sensorPin as INPUT_ANALOG: pinMode(sensorPin, INPUT_ANALOG); - // Declare the LED's pin as an OUTPUT. (BOARD_LED_PIN is a built-in + // Declare the LED's pin as an OUTPUT. (33 is a built-in // constant which is the pin number of the built-in LED. On the // Maple, it is 13.) - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); } void loop() { // Read the value from the sensor: sensorValue = analogRead(sensorPin); // Turn the LED pin on: - digitalWrite(BOARD_LED_PIN, HIGH); + digitalWrite(33, HIGH); // Stop the program for milliseconds: delay(sensorValue); // Turn the LED pin off: - digitalWrite(BOARD_LED_PIN, LOW); + digitalWrite(33, LOW); // Stop the program for for milliseconds: delay(sensorValue); } diff --git a/examples/Analog/Calibration/Calibration.ino b/examples/Analog/Calibration/Calibration.ino index 284bdfd..ca01d22 100644 --- a/examples/Analog/Calibration/Calibration.ino +++ b/examples/Analog/Calibration/Calibration.ino @@ -39,8 +39,8 @@ void setup() { // Turn on the built-in LED to signal the start of the calibration // period: - pinMode(BOARD_LED_PIN, OUTPUT); - digitalWrite(BOARD_LED_PIN, HIGH); + pinMode(33, OUTPUT); + digitalWrite(33, HIGH); // Calibrate during the first five seconds: while (millis() < 5000) { @@ -58,7 +58,7 @@ void setup() { } // Signal the end of the calibration period: - digitalWrite(BOARD_LED_PIN, LOW); + digitalWrite(33, LOW); } void loop() { @@ -72,5 +72,5 @@ void loop() { sensorValue = constrain(sensorValue, 0, 65535); // Fade the LED using the calibrated value: - pwmWrite(BOARD_LED_PIN, sensorValue); + pwmWrite(33, sensorValue); } diff --git a/examples/Communication/PhysicalPixel/PhysicalPixel.ino b/examples/Communication/PhysicalPixel/PhysicalPixel.ino index 76e72d3..4afbab0 100644 --- a/examples/Communication/PhysicalPixel/PhysicalPixel.ino +++ b/examples/Communication/PhysicalPixel/PhysicalPixel.ino @@ -28,7 +28,7 @@ int incomingByte; // a variable to read incoming serial data into void setup() { Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor // Initialize the built-in LED pin as an output: - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); } void loop() { @@ -38,11 +38,11 @@ void loop() { incomingByte = Serial.read(); // If it's a capital H (ASCII 72), turn on the LED: if (incomingByte == 'H') { - digitalWrite(BOARD_LED_PIN, HIGH); + digitalWrite(33, HIGH); } // If it's an L (ASCII 76) turn off the LED: if (incomingByte == 'L') { - digitalWrite(BOARD_LED_PIN, LOW); + digitalWrite(33, LOW); } } } diff --git a/examples/Control/IfStatementConditional/IfStatementConditional.ino b/examples/Control/IfStatementConditional/IfStatementConditional.ino index 3afeeb1..ab52c8e 100644 --- a/examples/Control/IfStatementConditional/IfStatementConditional.ino +++ b/examples/Control/IfStatementConditional/IfStatementConditional.ino @@ -30,7 +30,7 @@ const int threshold = 400; // A random threshold level that's in void setup() { Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor // Initialize the built-in LED pin as an output: - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); // Initialize the potentiometer pin as an analog input: pinMode(analogPin, INPUT_ANALOG); @@ -42,10 +42,10 @@ void loop() { // If the analog value is high enough, turn on the LED: if (analogValue > threshold) { - digitalWrite(BOARD_LED_PIN, HIGH); + digitalWrite(33, HIGH); } else { - digitalWrite(BOARD_LED_PIN, LOW); + digitalWrite(33, LOW); } // Print the analog value: diff --git a/examples/Control/WhileStatementConditional/WhileStatementConditional.ino b/examples/Control/WhileStatementConditional/WhileStatementConditional.ino index b4f22a7..20dcfae 100644 --- a/examples/Control/WhileStatementConditional/WhileStatementConditional.ino +++ b/examples/Control/WhileStatementConditional/WhileStatementConditional.ino @@ -37,7 +37,7 @@ int sensorValue = 0; // the sensor value void setup() { // set the LED pins as outputs and the switch pin as input: pinMode(ledPin, OUTPUT); // LED on pin 9 - pinMode(BOARD_LED_PIN, OUTPUT); // Built-in LED + pinMode(33, OUTPUT); // Built-in LED pinMode(BOARD_BUTTON_PIN, INPUT); // Built-in button } @@ -49,7 +49,7 @@ void loop() { calibrate(); } // signal the end of the calibration period - digitalWrite(BOARD_LED_PIN, LOW); + digitalWrite(33, LOW); // read the sensor: sensorValue = analogRead(sensorPin); @@ -66,7 +66,7 @@ void loop() { void calibrate() { // turn on the built-in LED to indicate that calibration is happening: - digitalWrite(BOARD_LED_PIN, HIGH); + digitalWrite(33, HIGH); // read the sensor: sensorValue = analogRead(sensorPin); diff --git a/examples/Digital/Blink/Blink.ino b/examples/Digital/Blink/Blink.ino index 2730873..c42a1ff 100644 --- a/examples/Digital/Blink/Blink.ino +++ b/examples/Digital/Blink/Blink.ino @@ -1,19 +1,32 @@ /* - Blink + Blink + Turns on an LED on for one second, then off for one second, repeatedly. - Turns on the built-in LED on for one second, then off for one second, - repeatedly. + Most Arduinos have an on-board LED you can control. On the Uno and + Leonardo, it is attached to digital pin 13. If you're unsure what + pin the on-board LED is connected to on your Arduino model, check + the documentation at http://arduino.cc - Ported to Maple from the Arduino example 27 May 2011 - By Marti Bolivar -*/ + This example code is in the public domain. + modified 8 May 2014 + by Scott Fitzgerald + + Modified by Roger Clark. www.rogerclark.net for Maple mini 25th April 2015 , where the LED is on PB1 + + */ + + +// the setup function runs once when you press reset or power the board void setup() { - // Set up the built-in LED pin as an output: - pinMode(BOARD_LED_PIN, OUTPUT); + // initialize digital pin PB1 as an output. + pinMode(PB1, OUTPUT); } +// the loop function runs over and over again forever void loop() { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off - delay(1000); // Wait for 1 second (1000 milliseconds) + digitalWrite(PB1, HIGH); // turn the LED on (HIGH is the voltage level) + delay(1000); // wait for a second + digitalWrite(PB1, LOW); // turn the LED off by making the voltage LOW + delay(1000); // wait for a second } diff --git a/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino b/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino index 78b4c5e..35f7a76 100644 --- a/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino +++ b/examples/Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino @@ -19,7 +19,7 @@ int interval = 1000; // interval at which to blink (in milliseconds) void setup() { // Set up the built-in LED pin as output: - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); } void loop() { @@ -32,6 +32,6 @@ void loop() { previousMillis = millis(); // If the LED is off, turn it on, and vice-versa: - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off } } diff --git a/examples/Digital/Button/Button.ino b/examples/Digital/Button/Button.ino index d438e4c..a27e92b 100644 --- a/examples/Digital/Button/Button.ino +++ b/examples/Digital/Button/Button.ino @@ -10,7 +10,7 @@ void setup() { // Initialize the built-in LED pin as an output: - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); // Initialize the built-in button (labeled BUT) as an input: pinMode(BOARD_BUTTON_PIN, INPUT); } @@ -31,6 +31,6 @@ void loop() { // Check if the button is pressed. if (isButtonPressed()) { // If so, turn the LED from on to off, or from off to on: - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off } } diff --git a/examples/Digital/Debounce/Debounce.ino b/examples/Digital/Debounce/Debounce.ino index 3c19cbb..b9fecc5 100644 --- a/examples/Digital/Debounce/Debounce.ino +++ b/examples/Digital/Debounce/Debounce.ino @@ -23,7 +23,7 @@ int debounceDelay = 50; // the debounce time; increase if the output flicker void setup() { pinMode(BOARD_BUTTON_PIN, INPUT); - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); } void loop() { @@ -47,7 +47,7 @@ void loop() { } // set the LED using the state of the button: - digitalWrite(BOARD_LED_PIN, buttonState); + digitalWrite(33, buttonState); // save the reading. Next time through the loop, // it'll be the lastButtonState: diff --git a/examples/Digital/MapleMorse/MapleMorse.ino b/examples/Digital/MapleMorse/MapleMorse.ino new file mode 100644 index 0000000..5e7d912 --- /dev/null +++ b/examples/Digital/MapleMorse/MapleMorse.ino @@ -0,0 +1,56 @@ +/* + Blink + + Turns on the built-in LED on for one second, then off for one second, + repeatedly. + + Ported to Maple from the Arduino example 27 May 2011 + By Marti Bolivar + + Updated for to remove definition for BOARD_LED_PIN by Roger Clark www.rogerclark.net 25th April 2015 + + Note. This code only works on the Maple mini and other boards where the LED is on GPIO PB1 aka pin 33 on the Maple mini silk screen + + I could not resist making this a bit more interesting than the simple blinking on and off, as I expect most users of this hardware will understand how + + +*/ +#define LED_PIN PB1 +#define TIMECONSTANT 100 + +void setup() { + // Set up the built-in LED pin as an output: + pinMode(LED_PIN, OUTPUT); +} + +void loop() { + sendMorse("-- .- .--. .-.. . "); +} + +void sendMorse(char *dotsAndDashes) +{ + while(*dotsAndDashes!=0) + { + switch(*dotsAndDashes) + { + case '-': + digitalWrite(LED_PIN,HIGH); + delay(TIMECONSTANT*3); + digitalWrite(LED_PIN,LOW); + delay(TIMECONSTANT); + break; + case '.': + digitalWrite(LED_PIN,HIGH); + delay(TIMECONSTANT); + digitalWrite(LED_PIN,LOW); + delay(TIMECONSTANT); + break; + case ' ': + default: + digitalWrite(LED_PIN,LOW); + delay(TIMECONSTANT*3); + break; + } + dotsAndDashes++; + } +} diff --git a/examples/Digital/StateChangeDetection/StateChangeDetection.ino b/examples/Digital/StateChangeDetection/StateChangeDetection.ino index 8c3a39f..545cf43 100644 --- a/examples/Digital/StateChangeDetection/StateChangeDetection.ino +++ b/examples/Digital/StateChangeDetection/StateChangeDetection.ino @@ -30,7 +30,7 @@ void setup() { // initialize the button pin as a input: pinMode(BOARD_BUTTON_PIN, INPUT); // initialize the LED as an output: - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); } void loop() { @@ -63,8 +63,8 @@ void loop() { // modulo of the button push counter. Modulo (percent sign, %) // gives you the remainder of the division of two numbers: if (buttonPushCounter % 4 == 0) { - digitalWrite(BOARD_LED_PIN, HIGH); + digitalWrite(33, HIGH); } else { - digitalWrite(BOARD_LED_PIN, LOW); + digitalWrite(33, LOW); } } diff --git a/examples/Maple/InteractiveTest/InteractiveTest.ino b/examples/Maple/InteractiveTest/InteractiveTest.ino index 1f0460f..2cc6ffa 100644 --- a/examples/Maple/InteractiveTest/InteractiveTest.ino +++ b/examples/Maple/InteractiveTest/InteractiveTest.ino @@ -23,7 +23,7 @@ const char* dummy_data = ("qwertyuiopasdfghjklzxcvbnmmmmmm,./1234567890-=" void setup() { Serial.begin(115200); // Ignored by Maple. But needed by boards using hardware serial via a USB to Serial adaptor // Set up the LED to blink - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); // Start up the serial ports Serial1.begin(BAUD); @@ -48,7 +48,7 @@ void setup() { } void loop () { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); while (Serial.available()) { @@ -248,7 +248,7 @@ void cmd_print_help(void) { void cmd_adc_stats(void) { Serial.println("Taking ADC noise stats."); - digitalWrite(BOARD_LED_PIN, 0); + digitalWrite(33, 0); for (uint32 i = 0; i < BOARD_NR_ADC_PINS; i++) { delay(5); measure_adc_noise(boardADCPins[i]); @@ -596,8 +596,8 @@ void cmd_board_info(void) { // TODO print more information Serial.print("* Clock speed (cycles/us): "); Serial.println(CYCLES_PER_MICROSECOND); - Serial.print("* BOARD_LED_PIN: "); - Serial.println(BOARD_LED_PIN); + Serial.print("* 33: "); + Serial.println(33); Serial.print("* BOARD_BUTTON_PIN: "); Serial.println(BOARD_BUTTON_PIN); diff --git a/examples/Maple/QASlave/QASlave.ino b/examples/Maple/QASlave/QASlave.ino index b78190f..b09c7de 100644 --- a/examples/Maple/QASlave/QASlave.ino +++ b/examples/Maple/QASlave/QASlave.ino @@ -25,7 +25,7 @@ void interToggleDelay(void); void setup() { - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); pinMode(BOARD_BUTTON_PIN, INPUT); // All unused pins start out low. @@ -38,9 +38,9 @@ void setup() { } void loop() { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off for (int i = 0; i < BOARD_NR_GPIO_PINS; i++) { if (boardUsesPin(i)) diff --git a/examples/MrBrunetteExamples/Blink/Blink.ino b/examples/MrBrunetteExamples/Blink/Blink.ino index 6d515a0..d59a711 100644 --- a/examples/MrBrunetteExamples/Blink/Blink.ino +++ b/examples/MrBrunetteExamples/Blink/Blink.ino @@ -8,10 +8,10 @@ void setup() { // Set up the built-in LED pin as an output: - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); } void loop() { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(1000); // Wait for 1 second (1000 milliseconds) } diff --git a/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino b/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino index 2981d9c..5d617f6 100644 --- a/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino +++ b/examples/MrBrunetteExamples/BlinkNcount/BlinkNcount.ino @@ -11,22 +11,22 @@ int n = 0; void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); // Initialize virtual COM over USB on Maple Mini Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Blink LED & count Demo"); } void loop() { - digitalWrite(BOARD_LED_PIN, HIGH); // set the LED on + digitalWrite(33, HIGH); // set the LED on delay(500); // wait for a second - digitalWrite(BOARD_LED_PIN, LOW); // set the LED off + digitalWrite(33, LOW); // set the LED off Serial.print("Loop #: "); n++; Serial.println(n); diff --git a/examples/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino b/examples/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino index 8a48a71..0f8516a 100644 --- a/examples/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino +++ b/examples/MrBrunetteExamples/FadingOnboard/FadingOnboard.ino @@ -14,7 +14,7 @@ // int ledPin = 9; // Connect an LED to digital pin 9, or any other // PWM-capable pin -int ledPin = BOARD_LED_PIN; +int ledPin = 33; void setup() { pinMode(ledPin, PWM); // setup the pin as PWM } diff --git a/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino b/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino index c6be14d..f732b50 100644 --- a/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino +++ b/examples/MrBrunetteExamples/IntegerInput/IntegerInput.ino @@ -14,13 +14,13 @@ int b; void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.setTimeout(timeoutPeriod); // default is 1 second // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } } diff --git a/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino b/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino index a0eaa0b..0f9c6ad 100644 --- a/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino +++ b/examples/MrBrunetteExamples/IntegerInput_FloatOutput/IntegerInput_FloatOutput.ino @@ -15,13 +15,13 @@ float b; void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART Serial.setTimeout(timeoutPeriod); // default is 1 second // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Integer Input - Floating Output"); diff --git a/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino b/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino index 956021b..6755e54 100644 --- a/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino +++ b/examples/MrBrunetteExamples/InternalTempSensor/InternalTempSensor.ino @@ -9,7 +9,7 @@ //#include #include -#define LED_PIN BOARD_LED_PIN +#define LED_PIN 33 #define A_RANDOM_ANALOG_PIN 15 void setup_temperature_sensor() { @@ -40,7 +40,7 @@ void setup(void) // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } @@ -73,7 +73,7 @@ void loop(void) sprintf(buf,"%04x %08x %04x %08x" , vsense, t3-t2, alogpin, t2-t1); Serial.println(buf); } - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(1000); } diff --git a/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino b/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino index ef50d73..7a57000 100644 --- a/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino +++ b/examples/MrBrunetteExamples/PrimeNos/PrimeNos.ino @@ -26,12 +26,12 @@ int primeFlag; void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Prime Number Generator"); diff --git a/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino b/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino index 50bd24f..2feca4b 100644 --- a/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino +++ b/examples/MrBrunetteExamples/PrimeNos2/PrimeNos2.ino @@ -15,12 +15,12 @@ int count = found - 1; void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Prime Number Generator V2"); diff --git a/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino b/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino index 30762c5..55ebafe 100644 --- a/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino +++ b/examples/MrBrunetteExamples/PrimeNos3/PrimeNos3.ino @@ -15,12 +15,12 @@ int count = found - 1; void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Prime Number Generator V2"); diff --git a/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino b/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino index 7353b4a..e6c02f9 100644 --- a/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino +++ b/examples/MrBrunetteExamples/Print_Binary/Print_Binary.ino @@ -12,12 +12,12 @@ void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Print Binary Format"); diff --git a/examples/MrBrunetteExamples/Print_Float/Print_Float.ino b/examples/MrBrunetteExamples/Print_Float/Print_Float.ino index 4dd0149..671caef 100644 --- a/examples/MrBrunetteExamples/Print_Float/Print_Float.ino +++ b/examples/MrBrunetteExamples/Print_Float/Print_Float.ino @@ -14,12 +14,12 @@ void setup() // run once, when the sketch starts { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Print Float Format"); diff --git a/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino b/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino index a4f5d69..0cdccd4 100644 --- a/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino +++ b/examples/MrBrunetteExamples/Print_HEX/Print_HEX.ino @@ -13,12 +13,12 @@ void setup() // run once, when the sketch starts { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UART // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Print HEX Format"); diff --git a/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino b/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino index b324554..1df080b 100644 --- a/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino +++ b/examples/MrBrunetteExamples/SerialReadUntil/SerialReadUntil.ino @@ -10,12 +10,12 @@ void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(BAUD); // BAUD has no effect on USB serial: placeholder for physical UAR // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("Serial Read Until Example:"); diff --git a/examples/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino b/examples/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino index 1740cc9..d98193c 100644 Binary files a/examples/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino and b/examples/MrBrunetteExamples/StringEx_Parsing/StringEx_Parsing.ino differ diff --git a/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino b/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino index 50f449e..17c7cb4 100644 --- a/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino +++ b/examples/MrBrunetteExamples/USB_ASCII/USB_ASCII.ino @@ -31,12 +31,12 @@ void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(); // USB does not require BAUD // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } Serial.println("ASCII Table ~ Character Map"); diff --git a/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino b/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino index a8e13aa..4507c78 100644 --- a/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino +++ b/examples/MrBrunetteExamples/strtol_DecEquivalents/strtol_DecEquivalents.ino @@ -16,12 +16,12 @@ template inline Print &operator <<(Print &obj, T arg) { obj.print(arg); void setup() { // initialize the digital pin as an output. - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); Serial.begin(9600); // wait for serial monitor to be connected. while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) { - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off delay(100); // fast blink } li1 = strtol (szNumbers,&pEnd,10); // BASE 10 diff --git a/examples/Sensors/Knock/Knock.ino b/examples/Sensors/Knock/Knock.ino index 1fabceb..70b8066 100644 --- a/examples/Sensors/Knock/Knock.ino +++ b/examples/Sensors/Knock/Knock.ino @@ -34,7 +34,7 @@ void setup() { // Declare the knockSensor as an analog input: pinMode(knockSensor, INPUT_ANALOG); // declare the built-in LED pin as an output: - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); } void loop() { @@ -44,7 +44,7 @@ void loop() { // if the sensor reading is greater than the threshold: if (sensorReading >= threshold) { // toggle the built-in LED - digitalWrite(BOARD_LED_PIN,!digitalRead(BOARD_LED_PIN));// Turn the LED from off to on, or on to off + digitalWrite(33,!digitalRead(33));// Turn the LED from off to on, or on to off // send the string "Knock!" back to the computer, followed by newline Serial.println("Knock!"); } diff --git a/examples/Stubs/DigitalReadWrite/DigitalReadWrite.ino b/examples/Stubs/DigitalReadWrite/DigitalReadWrite.ino index 9843d71..b352c10 100644 --- a/examples/Stubs/DigitalReadWrite/DigitalReadWrite.ino +++ b/examples/Stubs/DigitalReadWrite/DigitalReadWrite.ino @@ -1,9 +1,9 @@ void setup() { - pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(33, OUTPUT); } void loop() { int switchValue = digitalRead(2); - digitalWrite(BOARD_LED_PIN, switchValue); + digitalWrite(33, switchValue); }