Skip to content

Commit 3c6a2c5

Browse files
committed
resync the generic examples with arduino-1.8.5
1 parent 86df279 commit 3c6a2c5

File tree

43 files changed

+666
-754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+666
-754
lines changed

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/01.Basics/AnalogReadSerial/AnalogReadSerial.ino

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
/*
22
AnalogReadSerial
3-
Reads an analog input on pin 0, prints the result to the serial monitor.
4-
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
5-
6-
This example code is in the public domain.
7-
*/
3+
4+
Reads an analog input on pin 0, prints the result to the Serial Monitor.
5+
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
6+
Attach the center pin of a potentiometer to pin A0, and the outside pins to +3.3V and ground.
7+
8+
This example code is in the public domain.
9+
10+
http://www.arduino.cc/en/Tutorial/AnalogReadSerial
11+
*/
812

913
#include <Serial.h>
1014

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/01.Basics/BareMinimum/BareMinimum.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ void setup() {
44
}
55

66
void loop() {
7-
// put your main code here, to run repeatedly:
8-
7+
// put your main code here, to run repeatedly:
8+
99
}
Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
/*
22
Blink
3-
Turns on an LED on for one second, then off for one second, repeatedly.
4-
5-
This example code is in the public domain.
6-
*/
73
8-
#include <Arduino.h>
4+
Turns an LED on for one second, then off for one second, repeatedly.
5+
6+
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
7+
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
8+
the correct LED pin independent of which board is used.
9+
If you want to know what pin the on-board LED is connected to on your Arduino
10+
model, check the Technical Specs of your board at:
11+
https://www.arduino.cc/en/Main/Products
12+
13+
modified 8 May 2014
14+
by Scott Fitzgerald
15+
modified 2 Sep 2016
16+
by Arturo Guadalupi
17+
modified 8 Sep 2016
18+
by Colby Newman
19+
20+
This example code is in the public domain.
921
10-
// Pin 13 has an LED connected on most Arduino boards.
11-
// Pin 3 for the STM8S103 break out board
12-
// give it a name:
13-
int led = LED_BUILTIN;
22+
http://www.arduino.cc/en/Tutorial/Blink
23+
*/
1424

15-
// the setup routine runs once when you press reset:
16-
void setup() {
17-
// initialize the digital pin as an output.
18-
pinMode(led, OUTPUT);
25+
// the setup function runs once when you press reset or power the board
26+
void setup() {
27+
// initialize digital pin LED_BUILTIN as an output.
28+
pinMode(LED_BUILTIN, OUTPUT);
1929
}
2030

21-
// the loop routine runs over and over again forever:
31+
// the loop function runs over and over again forever
2232
void loop() {
23-
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
24-
delay(1000); // wait for a second
25-
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
26-
delay(1000); // wait for a second
33+
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
34+
delay(1000); // wait for a second
35+
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
36+
delay(1000); // wait for a second
2737
}

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/01.Basics/DigitalReadSerial/DigitalReadSerial.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/*
22
DigitalReadSerial
3-
Reads a digital input on pin 2, prints the result to the serial monitor
4-
5-
This example code is in the public domain.
6-
*/
3+
4+
Reads a digital input on pin 2, prints the result to the Serial Monitor
5+
6+
This example code is in the public domain.
7+
8+
http://www.arduino.cc/en/Tutorial/DigitalReadSerial
9+
*/
710

811
#include <Serial.h>
912

@@ -26,6 +29,3 @@ void loop() {
2629
Serial_println_u(buttonState);
2730
delay(1); // delay in between reads for stability
2831
}
29-
30-
31-

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/01.Basics/Fade/Fade.ino

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
11
/*
2-
Fade
3-
4-
This example shows how to fade an LED on pin 5
5-
using the analogWrite() function.
6-
7-
This example code is in the public domain.
8-
*/
2+
Fade
93
10-
#include <Arduino.h>
4+
This example shows how to fade an LED on pin 5 using the analogWrite()
5+
function.
116
12-
int led = 5; // the pin that the LED is attached to
7+
The analogWrite() function uses PWM, so if you want to change the pin you're
8+
using, be sure to use another PWM capable pin. On most Arduino, the PWM pins
9+
are identified with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
10+
11+
This example code is in the public domain.
12+
13+
http://www.arduino.cc/en/Tutorial/Fade
14+
*/
15+
16+
int led = 5; // the PWM pin the LED is attached to
1317
int brightness = 0; // how bright the LED is
1418
int fadeAmount = 5; // how many points to fade the LED by
1519

1620
// the setup routine runs once when you press reset:
17-
void setup() {
21+
void setup() {
1822
// declare pin 9 to be an output:
1923
pinMode(led, OUTPUT);
20-
}
24+
}
2125

2226
// the loop routine runs over and over again forever:
23-
void loop() {
27+
void loop() {
2428
// set the brightness of pin 9:
25-
analogWrite(led, brightness);
29+
analogWrite(led, brightness);
2630

2731
// change the brightness for next time through the loop:
2832
brightness = brightness + fadeAmount;
2933

30-
// reverse the direction of the fading at the ends of the fade:
31-
if (brightness == 0 || brightness == 255) {
32-
fadeAmount = -fadeAmount ;
33-
}
34-
// wait for 30 milliseconds to see the dimming effect
35-
delay(30);
34+
// reverse the direction of the fading at the ends of the fade:
35+
if (brightness <= 0 || brightness >= 255) {
36+
fadeAmount = -fadeAmount;
37+
}
38+
// wait for 30 milliseconds to see the dimming effect
39+
delay(30);
3640
}
37-

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/01.Basics/ReadAnalogVoltage/ReadAnalogVoltage.ino

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
/*
22
ReadAnalogVoltage
3-
Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
4-
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
5-
6-
This example code is in the public domain.
7-
*/
3+
4+
Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor.
5+
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
6+
Attach the center pin of a potentiometer to pin A0, and the outside pins to +3.3V and ground.
7+
8+
This example code is in the public domain.
9+
10+
http://www.arduino.cc/en/Tutorial/ReadAnalogVoltage
11+
*/
812

913
#include <Serial.h>
1014

sduino/hardware/sduino/stm8/libraries/Generic_Examples/examples/02.Digital/BlinkWithoutDelay/BlinkWithoutDelay.ino

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
1-
/* Blink without Delay
2-
3-
Turns on and off a light emitting diode (LED) connected to a digital
4-
pin, without using the delay() function. This means that other code
5-
can run at the same time without being interrupted by the LED code.
6-
7-
The circuit:
8-
* LED attached from pin 3 to VCC.
9-
* Note: on the STM8103 breakout board, there is already an LED on the board
10-
that's attached to pin 3, so no hardware is needed for this example.
11-
12-
created 2005
13-
by David A. Mellis
14-
modified 8 Feb 2010
15-
by Paul Stoffregen
16-
modified 11 Nov 2013
17-
by Scott Fitzgerald
18-
modified 13 Feb 2017 for use with sduino
19-
by Michael Mayer
20-
21-
22-
This example code is in the public domain.
23-
24-
http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
25-
*/
26-
27-
#include <Arduino.h>
28-
29-
// constants won't change. Used here to set a pin number :
30-
const int ledPin = 3; // the number of the LED pin
31-
32-
// Variables will change :
1+
/*
2+
Blink without Delay
3+
4+
Turns on and off a light emitting diode (LED) connected to a digital pin,
5+
without using the delay() function. This means that other code can run at the
6+
same time without being interrupted by the LED code.
7+
8+
The circuit:
9+
- Use the onboard LED.
10+
- Note: Most Arduinos have an on-board LED you can control. On the UNO, MEGA
11+
and ZERO it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN
12+
is set to the correct LED pin independent of which board is used.
13+
If you want to know what pin the on-board LED is connected to on your
14+
Arduino model, check the Technical Specs of your board at:
15+
https://www.arduino.cc/en/Main/Products
16+
17+
created 2005
18+
by David A. Mellis
19+
modified 8 Feb 2010
20+
by Paul Stoffregen
21+
modified 11 Nov 2013
22+
by Scott Fitzgerald
23+
modified 9 Jan 2017
24+
by Arturo Guadalupi
25+
modified 13 Feb 2017 for use with sduino
26+
by Michael Mayer
27+
28+
This example code is in the public domain.
29+
30+
http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
31+
*/
32+
33+
// constants won't change. Used here to set a pin number:
34+
const int ledPin = LED_BUILTIN;// the number of the LED pin
35+
36+
// Variables will change:
3337
int ledState = LOW; // ledState used to set the LED
3438

3539
// Generally, you should use "unsigned long" for variables that hold time
3640
// The value will quickly become too large for an int to store
3741
unsigned long previousMillis = 0; // will store last time LED was updated
3842

39-
// constants won't change :
43+
// constants won't change:
4044
const long interval = 1000; // interval at which to blink (milliseconds)
4145

4246
void setup() {
@@ -47,10 +51,9 @@ void setup() {
4751
void loop() {
4852
// here is where you'd put code that needs to be running all the time.
4953

50-
// check to see if it's time to blink the LED; that is, if the
51-
// difference between the current time and last time you blinked
52-
// the LED is bigger than the interval at which you want to
53-
// blink the LED.
54+
// check to see if it's time to blink the LED; that is, if the difference
55+
// between the current time and last time you blinked the LED is bigger than
56+
// the interval at which you want to blink the LED.
5457
unsigned long currentMillis = millis();
5558

5659
if (currentMillis - previousMillis >= interval) {
@@ -68,4 +71,3 @@ void loop() {
6871
digitalWrite(ledPin, ledState);
6972
}
7073
}
71-
Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
/*
22
Button
33
4-
Turns on and off a light emitting diode(LED) connected to digital
5-
pin 3, when pressing a pushbutton attached to pin 2.
4+
Turns on and off a light emitting diode(LED) connected to digital pin 3,
5+
when pressing a pushbutton attached to pin 2.
66
7+
The circuit:
8+
- LED attached from pin 3 to VCC
9+
- pushbutton attached to pin 2 from +5V
10+
- 10K resistor attached to pin 2 from ground
711
8-
The circuit:
9-
* LED attached from pin 3 to VCC
10-
* pushbutton attached to pin 2 from +5V
11-
* 10K resistor attached to pin 2 from ground
12+
- Note: on the STM8S103 breakout board there is already an LED on the board
13+
attached to pin 3.
1214
13-
* Note: on the STM8S103 breakout board there is already an LED on the board
14-
attached to pin 3.
15+
created 2005
16+
by DojoDave <http://www.0j0.org>
17+
modified 30 Aug 2011
18+
by Tom Igoe
19+
modified 13 Feb 2017 for use with sduino
20+
by Michael Mayer
1521
22+
This example code is in the public domain.
1623
17-
created 2005
18-
by DojoDave <http://www.0j0.org>
19-
modified 30 Aug 2011
20-
by Tom Igoe
21-
modified 13 Feb 2017 for use with sduino
22-
by Michael Mayer
24+
http://www.arduino.cc/en/Tutorial/Button
25+
*/
2326

24-
This example code is in the public domain.
25-
26-
http://www.arduino.cc/en/Tutorial/Button
27-
*/
28-
29-
#include <Arduino.h>
30-
31-
// constants won't change. They're used here to
32-
// set pin numbers:
27+
// constants won't change. They're used here to set pin numbers:
3328
const int buttonPin = 2; // the number of the pushbutton pin
3429
const int ledPin = 3; // the number of the LED pin
3530

@@ -47,13 +42,12 @@ void loop() {
4742
// read the state of the pushbutton value:
4843
buttonState = digitalRead(buttonPin);
4944

50-
// check if the pushbutton is pressed.
51-
// if it is, the buttonState is HIGH:
45+
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
5246
if (buttonState == HIGH) {
5347
// turn LED on:
5448
digitalWrite(ledPin, HIGH);
5549
} else {
5650
// turn LED off:
5751
digitalWrite(ledPin, LOW);
5852
}
59-
}
53+
}

0 commit comments

Comments
 (0)