Professional Documents
Culture Documents
Led Bar Graph Project
Led Bar Graph Project
Arduino project hand book Myanmar Arduino Learner (Ye Lin Naing )
Arduino project hand book Myanmar Arduino Learner (Ye Lin Naing )
လုိအပ္တဲ့ ပစၥည္းမ်ား
• Arduino board x 1
• Breadboard x 1
• Jumper wires x 13
• LED x 9
• 50k-ohm potentiometer x 1
• 220-ohm resistor x 9
3
Arduino project hand book Myanmar Arduino Learner (Ye Lin Naing )
Circuit Diagram
ပံုပါအတိုင္း ခ်ိတ္ဆက္ေပးပါ ။
သိမွတ္စရာ
ညာ ေပါင္း (+)
ဘယ္ အနုတ္ (-)
အလယ္ Output
4
Arduino project hand book Myanmar Arduino Learner (Ye Lin Naing )
Program ( SKETCH )
/*
*Program Name : Led Bar Graph
*/
const int Analog_input_Pin = A0; // Pin connected to the potentiometer
const int LedNumber = 9; // Number of LEDs
int ledPins[] = {2,3,4,5,6,7,8,9,10}; // Pins connected to the LEDs
void setup() {
for (int thisLed = 0; thisLed < LedNumber; thisLed++) {
// Set the LED pins as output
pinMode(ledPins[thisLed], OUTPUT);
}
}
void loop() {
// Receive Analog input
int InputValue = analogRead(Analog_input_Pin);
// input and output value Mapping
int ledLevel = map(InputValue, 0, 1023, 0, LedNumber );
Arduino project hand book Myanmar Arduino Learner (Ye Lin Naing )
ရွင္းလင္းခ်က္
void setup() {
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
// Set the LED pins as output
pinMode(ledPins[thisLed], OUTPUT);
}
}
ေပၚမွာ ေဖာ္ျပေပးခဲ့တဲ့ pin No ေတြကို Output အျဖစ္ အသံုးျပဳမည္
ဆိုသည့္အေၾကာင္းကို void setup ထဲမွာ ေၾကညာေပးျခင္းျဖစ္ပါတယ္ ။
For statement နဲ႔ Array အေၾကာင္းကို သိရင္ေတာ့ ေသခ်ာနားလည္
ပါလိမ့္မယ္။
void loop() {
// Receive Analog input
int InputValue = analogRead(Analog_input_Pin);
Analog pin မွ ရရွိေသာ တန္ဖိုးမ်ားကို Input value အျဖစ္
သက္မွတ္ေပးျခင္းျဖစ္ပါတယ္။
6
Arduino project hand book Myanmar Arduino Learner (Ye Lin Naing )
// input and output value Mapping
int ledLevel = map(InputValue, 0, 1023, 0, LedNumber);
ရရွိတဲ့ input တန္းဖိုးေတြဟာ 0 မွ 1023 အတြင္းမွာ ရွိေနမွာျဖစ္ျပီး ထုိတန္ဖိုးကို
အေရအတြက္ ၉လံုးရွိတဲ့ Led မီးတန္းအတြက္ ရွိရမယ့္ Led level အျဖစ္ Map
function ကို အသံုးျပဳကာ ၄င္းတန္ဖိုးႏွစ္ခုအား ယွဥ္တြဲ တြက္ထုတ္ေပးရမွာပဲ
ျဖစ္ပါတယ္ ။