Merge pull request #42 from ErikIOT/master
Added basic library examples for B-L475E-IOT01A
This commit is contained in:
commit
5f3e750d41
|
@ -0,0 +1,31 @@
|
|||
// Blink on-board LEDs
|
||||
|
||||
|
||||
/*
|
||||
#define LED_BUILTIN PA5
|
||||
#define LED2_BUILTIN PB14
|
||||
#define LED3_BUILTIN PC9 //Note LED3 and LED4 are both driven by PC9, but in reverse logic
|
||||
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
pinMode(LED2_BUILTIN, OUTPUT);
|
||||
pinMode(LED3_BUILTIN, OUTPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
digitalWrite(LED2_BUILTIN, HIGH);
|
||||
digitalWrite(LED3_BUILTIN, HIGH);
|
||||
delay(400);
|
||||
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
digitalWrite(LED2_BUILTIN, LOW);
|
||||
digitalWrite(LED3_BUILTIN, LOW);
|
||||
delay(300);
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// Print milliseconds to Serial monitor every second
|
||||
|
||||
void setup() {
|
||||
SerialUART1.stm32SetTX(PB6);
|
||||
SerialUART1.stm32SetRX(PB7);
|
||||
SerialUART1.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
SerialUART1.println(millis());
|
||||
delay(1000);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/* Reads incoming Serial data and responds accordingly.
|
||||
Send "L" to turn LED off
|
||||
Send "H" to turn LED on */
|
||||
|
||||
|
||||
int incomingByte; // variable to save incoming serial data
|
||||
|
||||
void setup() {
|
||||
// initialize SerialUART1 communication:
|
||||
SerialUART1.stm32SetTX(PB6);
|
||||
SerialUART1.stm32SetRX(PB7);
|
||||
SerialUART1.begin(115200);
|
||||
|
||||
// initialize the LED pin as an output:
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// see if there's incoming SerialUART1 data:
|
||||
if (SerialUART1.available() > 0) {
|
||||
|
||||
// read the oldest byte in the SerialUART1 buffer:
|
||||
|
||||
incomingByte = SerialUART1.read();
|
||||
|
||||
// if it's a capital H, turn on the LED:
|
||||
if (incomingByte == 'H') {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
SerialUART1.println("HIGH ");
|
||||
}
|
||||
|
||||
// if it's an L, turn off the LED:
|
||||
else if (incomingByte == 'L') {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
SerialUART1.println("LOW ");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
// show user button state with blinking LEDs
|
||||
// B-L475E-IOT01A Discovery has one user button
|
||||
|
||||
|
||||
/*
|
||||
#define LED_BUILTIN PA5
|
||||
#define LED2_BUILTIN PB14
|
||||
#define LED3_BUILTIN PC9 //Note LED3 and LED4 are both driven by PC9, but in reverse logic
|
||||
|
||||
//On-board user button
|
||||
#define USER_BUTTON PC13
|
||||
*/
|
||||
|
||||
int buttonState = 0; // variable for reading the pushbutton status
|
||||
|
||||
void setup() {
|
||||
pinMode(USER_BUTTON, INPUT_PULLUP);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
pinMode(LED2_BUILTIN, OUTPUT);
|
||||
pinMode(LED3_BUILTIN, OUTPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
buttonState = digitalRead(USER_BUTTON);
|
||||
|
||||
if (buttonState == 1) {
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
digitalWrite(LED2_BUILTIN, HIGH);
|
||||
digitalWrite(LED3_BUILTIN, HIGH);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
if (buttonState == 0) {
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
digitalWrite(LED2_BUILTIN, LOW);
|
||||
digitalWrite(LED3_BUILTIN, LOW);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue