“Lesson 1--Microduino "LED and a Breadboard"”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
Experimental schematic
Result
第110行: 第110行:
 
==Result==
 
==Result==
 
After the download, you can see LED flashes once every 1s.
 
After the download, you can see LED flashes once every 1s.
 +
 +
[[File:lesson1OK.jpg|600px|center|thumb]]
  
 
==Video==
 
==Video==
  
 
|}
 
|}

2015年7月2日 (四) 09:24的版本

Language English

Objective

Using Microduino to control a LED. Actually you can learn to how to use the Micrduino's I/O port. This is a basic skill you should master and for further study.

Equipment

Microduino-Core is a 8-bit microcontroller development board based on Atmel ATmega328P, ATmega168PA series, and is an open source, compatible with Arduino UNO controller module.

Detailed information, please refer to http://wiki.microduino.net/index.php?title=Microduino-Core

Download program module, connect with Microduino-Core or Microduino-Core+ directly and communicate with PC. It uses MicUSB as the download port. And it has the same size with a dollar coin. Download line with most smart phones usb data cable is the same, convenient and practical

Detailed information, please refer to http://wiki.microduino.net/index.php?title=Microduino-FT232R

  • Other hardware equipment
    • Breadboard Jumper one box
    • Breadboard one piece
    • LED Light-emitting diodes one
    • 220ohm resistor one
    • USB Data cable one
Lesson1Main.jpg
Lesson1All.jpg

Breadboard

In the vertical direction,5 points connected together and 25 points connected together in a horizontal direction. Some bread has 50 points connected together, so make sure connection format before you use it, in order to avoid generating erroneous results. The next two rows of points 50 have more usage, one row as GDN, the other row as VCC. Please refer to the following picture.

Breadboard.jpg

Resistor and LED

Limiting resistor is used to prevent LED burned. Usually red and green LED voltage is 1.8 ~ 2.4V, blue and white is 2.8 ~ 4.2V, 3mmLED rated current is 1 ~ 10mA, 5mmLED rated current is 5 ~ 25mA, and 10mmLED rated current is 25 ~ 100mA. According to R = U / I to the calculated resistance. Usually hundreds of ohm should be ok.

How to Judge the Electrode of a LED Light

Step 1: Take a look inside the LED light, the pin with a bigger bracket is negative and the one with a smaller bracket is positive. Step 2: For an all new LED light, you can tell the electrode from the length of the pin. The longer pin is positive and vice versa.

Test a LED Light via a Multimeter

When using the analog multimeter to test a diode, you must choose the "Rxl0k" stall since the voltage of the battery inside the multimeter is only 1.5V when the multimeter is under the "R×lk" stall, lower than the voltage drop of a 3V LED light. In that case, it is impossible to test LED lights no matter what connection method you adopt. While the analog multimeter is under the "R×l0k" stall, you can test the LED light for the voltage of the battery is about 9V(or 15V), higher than the voltage drop.

Since the black probe of the analog multimeter shows positive and the red probe shows negative, you need to connect the black probe to the positive of the LED light and the red probe to the negative. If the LED light goes on, then it works.

Different from the analog multimeter, the digital multimeter shows contrary electrode. Adopting right connection method, you can prove the LED light is good when seeing the light goes on.

Experimental schematic

There are two connection methods, one is that led cathode connects to GND, anode connects to Microduino digital I/O port 13, which is the high light led. The other method ist that led cathode connected Microduino digital I/O port 13, anode connects to VCC, so that low-level light led.

Schematic.jpg
Lesson1Setup.jpg

Program

  • Using delay() function:
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
}
  • Using function millis():Return the number of milliseconds from start running Microduino program to now.
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

  • Choose the board type in "tools", the "Microduino-Core(ATmega328P@16M,5V)" is used in this experiment. There are two types of 328 board, so you need identify which type board you are using. You can check the 0 resistor's connection method to identify.
Boardtype.jpg
  • Choose COM port.Matched serial port is different for everyone's computer, so you just need choose your own. The COM port is in "properties"->"device manager" in your computer, you also can double-click "Advanced" to change the COM port by port settings.
  • Compile downloads
Compile.jpg
Download.jpg

Result

After the download, you can see LED flashes once every 1s.

Lesson1OK.jpg

Video