
8X32 Red Dot Matrix with Bluetooth Control Project
8×8 Dot Matrix Module တခုကို အသုံးပြုပြီး ရေးထားတဲ့ Project ကို ဤ နေရာ တွင် ဖတ်ရှုနိုင်သည်။
ဒီ Project မှာ 8X32 Dot Matrix ကို သုံးပြီး Project လုပ်ထားတဲ့ အပြင် Bluetooth က ထိန်းချုပ်ပြီး မိမိ ပြသစေလိုသော စာလုံးများကို ပြောင်းလဲ ပြသဦးမှာပါ။ ဒီ Project ကို စမ်းသပ်ပြီးပါက 8×32 Dot Matrix Led Module အသုံးပြုပုံ၊ Scrolling Text (ရွေ့လျားနေသာ စာသားများ ) ထည့်သွင်း အသုံးပြုပုံ၊ Bluetooth Module ချိန်ဆက် အသုံးပြုပုံတို့အပြင် Android Apk ကို MIT App Inventor အသုံးပြု ရေးသားပုံတို့ကိုပါ လေ့လာ သိရှိသွားမည်ဖြစ်သည်။
Wiring Diagram
(ပုံအကြီး ကြည့်လိုပါက ပုံကို နှိပ်ပြီး ကြည့်နိုင်သည်)
Arduino Code
/*
Project: 8×8 Dot Matrix ၄ ခုကို ချိတ်ဆက်ထားပြီး ရွေ့လျားနေသော စာလုံးများကို ပြသမည်
Adafruit’s GFX နှင့် Mark Ruys’ Max72xxPanel libraries များကို သုံးဖို့ လိုအပ်ပါမည်။
စာသာများပြောင်းလဲခြင်းကို UART မှ တဆင့် ပြုလုပ်မည်ဖြစ်သည်။
UART မှ command များပေးပို့မှု ချက်ချင်းသိရင် External Interrupt Pin 2 ကို အသုံးပြုထားပြီး Rx (Pin 0) နှင့် Pin 2 ကို 1K Ohm Resistor
ဖြင့် ချိတ်ဆက်ထားဖို့လိုသည်။
Here are the commands Arduino recognizes.
1. Any character stream must be sent enclosed inside parenthesis.
Example: “Hello! How are you doing?” ပြသလိုပါက (Hello! How are you doing?) ဟုပေးပို့ပါ။
( ဖြင့် စသော စာလုံးများ အတိုင်းပြမည်။
2. /+ or /- သည် အလင်း အမှောင် ကို ချိန်ညှိခြင်းဖြစ်သည်။
3. /< or /> မြန်မြန်ရွေ့လျားမည်။ (သို့) နှေးကွေးစွာ ရွေ့လျားမည်။
4. /p စာသားများ မရွေ့လျားပဲ ရပ်နေမည်
5. /e သိမ်းထားသော စာသာများကို ဖျက်ပစ်မည်။
Connections:
Easy Matrix Arduino
VCC +5V
DIN MOSI (Pin 11)
LOAD pinCS (Pin 10)
CLK SCK (Pin 13)
GND Gnd
UART Baud Rate = 9600 baud.
မူရင်းရေးသားသူ: Rajendra Bhatt
*/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
#include <SPI.h> #include <Adafruit_GFX.h> #include <Max72xxPanel.h> int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI ) int numberOfHorizontalDisplays = 8; int numberOfVerticalDisplays = 1; Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays); int scrollspeed = 200; // Default scrollspeed (milliseconds) int spacer = 1; // Space between two characters int width = 5 + spacer; // The font width is 5 pixels boolean inChar = false, NewData = false, pause = false; boolean relay1=false, relay2=false; boolean dataAvailable = false; char inputString[512]; int count = 0, BTvalue = 5; void setup() { matrix.setIntensity(1); // Use a value between 0 and 15 for brightness // Adjust to your own needs matrix.setPosition(0, 7, 0); // The first display is at <0, 7> matrix.setPosition(1, 6, 0); // The second display is at <1, 0> matrix.setPosition(2, 5, 0); // The third display is at <2, 0> matrix.setPosition(3, 4, 0); // And the last display is at <3, 0> matrix.setPosition(4, 3, 0); // The first display is at <0, 0> matrix.setPosition(5, 2, 0); // The second display is at <1, 0> matrix.setPosition(6, 1, 0); // The third display is at <2, 0> matrix.setPosition(7, 0, 0); // And the last display is at <3, 0> // ... matrix.setRotation(0, 3); // The first display is position upside down matrix.setRotation(1, 3); // The first display is position upside down matrix.setRotation(2, 3); // The first display is position upside down matrix.setRotation(3, 3); // The same hold for the last display matrix.fillScreen(0); matrix.write(); Serial.begin(9600); // serial communication initialize // Using interrupt 0 on digital pin 2. pinMode(2, INPUT); pinMode(5, OUTPUT); // relay 1 Control pinMode(6, OUTPUT); // relay 2 Control digitalWrite(2, LOW); digitalWrite(5, HIGH); digitalWrite(6, HIGH); attachInterrupt(0, serialInterrupt, CHANGE); } void loop(){ if(dataAvailable){ display_data(); } } void display_data(){ for ( int i = 0 ; i < width * count + matrix.width() - 1 - spacer; i++ ) { matrix.fillScreen(0); int letter = i / width; int x = (matrix.width() - 1) - i % width; int y = (matrix.height() - 8) / 2; // center the text vertically while ( x + width - spacer >= 0 && letter >= 0 ) { if ( letter < count ) { matrix.drawChar(x, y, inputString[letter], HIGH, LOW, 1); } letter--; x -= width; } matrix.write(); // Send bitmap to display if(!dataAvailable){ i = width * count + matrix.width() - 1 - spacer; matrix.fillScreen(LOW); matrix.write(); } if(NewData){ i = 0; matrix.fillScreen(LOW); matrix.write(); NewData = false; } while(pause == true){ delay(0); } // Pause here if pause command is received delay(scrollspeed); } } // Volatile, since it is modified in an ISR. volatile boolean inService = false; void serialInterrupt(){ if (inService) return; // You was not in service. Now you are. inService = true; // Reenable interrupts, to allow Serial to work. We do this only if inService is false. interrupts(); while(!Serial.available()); while (Serial.available()) { char ch = Serial.read(); if(ch =='('){ count = 0; inChar = true; while(inChar){ if (Serial.available()) { ch = Serial.read(); if(ch == ')'){ inChar = false; dataAvailable = true; } else{ inputString[count] = ch; count++; } if(count > 0) { NewData = true; } } } } if(ch =='/'){ // Command mode inChar = true; while(inChar){ if (Serial.available()) { ch = Serial.read(); // '/+' is for brightness increment if(ch == '+'){ if(BTvalue < 15) { BTvalue ++; matrix.setIntensity(BTvalue); } break; } // '/-' is for brightness decrement if(ch == '-'){ if(BTvalue > 0){ BTvalue --; matrix.setIntensity(BTvalue); } break; } // '/>' is to slow down scroll if(ch == '>'){ if(scrollspeed < 500) { scrollspeed = scrollspeed + 50; } break; } // '/<' is to make scroll faster if(ch == '<'){ if(scrollspeed > 50){ scrollspeed=scrollspeed-50; } break; } // '/e' is to erase display if(ch == 'e'){ dataAvailable = false; break; } // '/p' is to pause display if(ch == 'p'){ if(pause == false){ pause = true; } else { pause = false; } break; } // '/1' is to relay 1 control if(ch == '1'){ if(relay1 == false){ relay1 = true; digitalWrite(5, HIGH); } else { relay1 = false; digitalWrite(5, LOW); } break; } if(ch == '2'){ if(relay2 == false){ relay2 = true; digitalWrite(6, HIGH); } else { relay2 = false; digitalWrite(6, LOW); } break; } else { break; // Unrecognized command } } } } // if(ch == '!') } // while(serial.available) inService = false; } |
Android Code
MIT App Inventor .aia File ကို ဤ နေရာ တွင် ဒေါင်းလုပ် လုပ်ယူနိုင်ပါသည်။
Video
သီဟကျော်