> Club Elektronika: Clubek 2: MySQL to PHP to c++ to Arduino to LED KIT Module

Clubek 2: MySQL to PHP to c++ to Arduino to LED KIT Module



Arduino Uno R3: 29 CHF
Proyek yang merupakan variasi dari proyek clubek1 tentang bagaimana mengambil data dari database MySQL dan menampilkannya di 7 segment LED Display. Variasinya adalah rangkaian Display di clubek 1 di ganti dengan LED Kit Module.







 --------------------------------------------------------------------------------------------------------------

Shifout LED Kit: 13 CHF
 Penjelasan proyek clubek 2 dengan program arduinonya




//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 3;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 9;
byte Tab[]={
  0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
  Serial.begin(9600);
  Serial.println("reset");
  for(int i = 0;i < 10; i++){
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, Tab[i]);
    digitalWrite(latchPin, HIGH);
    delay(500);
  }
}
void loop() {
  if (Serial.available() > 0) {
    // ASCII '0' through '9' characters are
    // represented by the values 48 through 57.
    // so if the user types a number from 0 through 9 in ASCII, 
    // you can subtract 48 to get the actual value:
    int bitToSet = Serial.read() - 48;
    // write to the shift register with the correct bit set high:
    digitalWrite(latchPin, LOW);
    // shift the bits out:
    shiftOut(dataPin, clockPin, MSBFIRST, Tab[bitToSet]);
    // turn on the output so the LEDs can light up:
    digitalWrite(latchPin, HIGH);
  }
}
sumber: www.dfrobot.com/wiki/index.php?title=Shift_out_LED_kit_%28SKU:DFR0089%29

Tidak ada komentar :

Posting Komentar