Difference between revisions of "Maple Lesson 01 - Blinking LED"
From Microduino Wiki
(Created page with "{| style="width: 800px;" |- | == Objective == Using Microduino-CoreSTM32 to control the on-board LED. Actually you can learn to how to use the Micrduino-CoreSTM32's I/O port. ...") |
(→Prerequisites) |
||
Line 7: | Line 7: | ||
== Prerequisites == | == Prerequisites == | ||
− | *'''[[Setting Up Maple IDE for Microduino-CoreSTM32 | + | *'''[[Setting Up Maple IDE for Microduino-CoreSTM32]]''' |
== Equipment == | == Equipment == |
Revision as of 00:31, 15 July 2014
ContentsObjectiveUsing Microduino-CoreSTM32 to control the on-board LED. Actually you can learn to how to use the Micrduino-CoreSTM32's I/O port. This is a basic skill you should master and for further study. PrerequisitesEquipmentMicroduino-CoreSTM32 is a 32-bit ARM Cortex-M3 development board, based on STMicroelectronics' STM32F103CBT6.
Program
int led = 13;// Define the PIN
void setup() {
pinMode(led, OUTPUT); // Define the I/O port 13 as output
}
void loop() {
digitalWrite(led, HIGH); //I/O port 13 output High. If the connection is high lighted,the LED will light, otherwise extinguished
delay(1000); // delay 1s
digitalWrite(led, LOW); //I/O port 13 output Low.If the connection is high lighted,the LED off, otherwise light.
delay(1000); // delay 1s
}
int ledPin=13;
#define TIME 1000
long time1=0,time2=0;
void setup()
{
pinMode(ledPin,OUTPUT);
}
void loop()
{
if(millis()<time2+TIME)
{
digitalWrite(ledPin,HIGH);
time1=millis();
}
else
{
digitalWrite(ledPin,LOW);
if(millis()>time1+TIME)
time2=millis();
}
} Using function millis () is better than the delay () function, less resource and fewer delays on the system. Download program method
ResultAfter the download, you can see LED flashes once every 1s. Video |