Removed BOARD_LED_PIN and button pin definitions as they are not core Arduino API definitions and they were causing confusion on users of generic stm32 boards which don't all have an LED and even if they have an LED, the pin it is on is not always on the same pin depending on the model of generic board

This commit is contained in:
rogerclarkmelbourne 2015-04-25 10:41:27 +10:00
parent 4d3c370314
commit badf7057f0
48 changed files with 175 additions and 174 deletions

View File

@ -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[];

View File

@ -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.
*

View File

@ -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);
}

View File

@ -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
};

View File

@ -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

View File

@ -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
};

View File

@ -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

View File

@ -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
};

View File

@ -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

View File

@ -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
};

View File

@ -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

View File

@ -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
};

View File

@ -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

View File

@ -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
};

View File

@ -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

View File

@ -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
};

View File

@ -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

View File

@ -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 <sensorValue> milliseconds:
delay(sensorValue);
// Turn the LED pin off:
digitalWrite(BOARD_LED_PIN, LOW);
digitalWrite(33, LOW);
// Stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}

View File

@ -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);
}

View File

@ -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);
}
}
}

View File

@ -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:

View File

@ -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);

View File

@ -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
}

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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:

View File

@ -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++;
}
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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))

View File

@ -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)
}

View File

@ -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);

View File

@ -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
}

View File

@ -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
}
}

View File

@ -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");

View File

@ -9,7 +9,7 @@
//#include <stdio.h>
#include <libmaple/adc.h>
#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);
}

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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");

View File

@ -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:");

View File

@ -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");

View File

@ -16,12 +16,12 @@ template<class T> 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

View File

@ -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!");
}

View File

@ -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);
}