Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Exhibition / Re: 8x8 LED Dot Matrix 2 Color + Freeduino on: April 16, 2010, 03:36:03 pm
Sciguy
Thank you. For instructions.  smiley




595                 595               595                  Freeduino
PIN 16  <==> PIN 16 <==> PIN 16 ====>  digital pin 13
PIN 12  <==> PIN 12 <==> PIN 12 ====>  digital pin 8
PIN 11  <==> PIN 11 <==> PIN 11 ====>  digital pin 12
pin  14  ======================>  digital pin  9
                      pin  14 =============>  digital pin 10
                                          pin  14 ====>  digital pin  11


retrolefty
This is my code.

Code:
int latchPin = 8;
int clockPin = 12;

int dataPin = 9;
int dataPinRed = 10;
int dataPinGreen = 11;

int powerPin = 13;

byte data;

byte dataArray[22];

int Red = 1;
int Green = 2;
int Orange = 3;

void setup() {

  pinMode(latchPin, OUTPUT);
  pinMode(powerPin,OUTPUT);
  digitalWrite(powerPin,HIGH);
  
  myarray();

}

void loop(){
  
  for(int i = 0 ; i <= 5000 ; i++){
  dotshow(random(1, 9),random(1, 9),random(1, 3));
  delay(1);}
  
  
  
  for(int c = 1 ; c <= 3 ; c++){
  for(int i = 1 ; i <= 8 ; i++){
  rowshow(i,c);
  delay(100);}
  for(int i = 8 ; i >= 1 ; i--){
  rowshow(i,c);
  delay(100);}
  dotshow(0,0,c);
  delay(500);
  }
  
  for(int c = 1 ; c <= 3 ; c++){
  for(int i = 1 ; i <= 8 ; i++){
  colshow(i,c);
  delay(100);}
  for(int i = 8 ; i >= 1 ; i--){
  colshow(i,c);
  delay(100);}
  dotshow(0,0,c);
  delay(500);
  }
  
 
  for(int i = 0 ; i <= 30 ; i++){
  fourshow(random(1, 3),random(1, 3),random(1, 4));
  delay(300);}




}


void dotshow(int myRow,int myCol, int color){

    byte dotRow;
    byte dotColRed;
    byte dotColGreen;
   
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3649][ch3606][ch3623][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621]
    for(int i = 1; i <= 8 ; i++){
    if( myRow == i){dotRow = dataArray[8 - i];}}
   
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3588][ch3629][ch3621][ch3633][ch3617][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621] + [ch3585][ch3635][ch3627][ch3609][ch3604][ch3626][ch3637]
    for(int i = 1; i <= 8 ; i++){
    if(myCol == i){
    if(color == 0){ dotColRed =dataArray[16] ;   dotColGreen =dataArray[16];}
    if(color == 1){ dotColRed =dataArray[16] ;  dotColGreen =dataArray[16-i];}
    if(color == 2){ dotColRed =dataArray[16-i] ;  dotColGreen =dataArray[16];}
    if(color == 3){ dotColRed =dataArray[16-i] ;  dotColGreen =dataArray[16-i];}}}
   
    //[ch3649][ch3626][ch3604][ch3591][ch3607][ch3640][ch3585] Dot
    if(myRow == 0 && myCol == 0){ dotRow = dataArray[16];
    if(color == 1){ dotColRed =dataArray[16] ;  dotColGreen =dataArray[17];}
    if(color == 2){ dotColRed =dataArray[17] ; dotColGreen =dataArray[16];}
    if(color == 3){ dotColRed =dataArray[17] ;  dotColGreen =dataArray[17];}}
   
    //[ch3649][ch3626][ch3604][ch3591][ch3612][ch3621]
    digitalWrite(latchPin, 0);
    shiftOut(dotRow,dotColRed,dotColGreen);
    digitalWrite(latchPin, 1);

}

//____________ [ch3649][ch3626][ch3604][ch3591][ch3607][ch3637][ch3656][ch3621][ch3632][ch3649][ch3606][ch3623]

void rowshow(int myRow,int color)
{
    byte dotRow;
    byte dotColRed;
    byte dotColGreen;
   
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3649][ch3606][ch3623][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621]
    for(int i = 1; i <= 8 ; i++){
    if( myRow == i){dotRow = dataArray[8 - i];}}
   
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3626][ch3637]
    if(color == 0){ dotColRed =dataArray[16] ;  dotColGreen =dataArray[16];}
    if(color == 1){ dotColRed =dataArray[16] ;  dotColGreen =dataArray[17];}
    if(color == 2){ dotColRed =dataArray[17] ;  dotColGreen =dataArray[16];}
    if(color == 3){ dotColRed =dataArray[17] ;  dotColGreen =dataArray[17];}
  
    digitalWrite(latchPin, 0);
    shiftOut(dotRow,dotColRed,dotColGreen);
    digitalWrite(latchPin, 1);
  
 }
 
 //____________ [ch3649][ch3626][ch3604][ch3591][ch3607][ch3637][ch3656][ch3588][ch3629][ch3621][ch3633][ch3617]
 void colshow(int myCol,int color)
{
   
    byte dotColRed;
    byte dotColGreen;
   
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3588][ch3629][ch3621][ch3633][ch3617][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621] + [ch3585][ch3635][ch3627][ch3609][ch3604][ch3626][ch3637]
    for(int i = 1; i <= 8 ; i++){
    if(myCol == i){
    if(color == 0){ dotColRed =dataArray[16] ;   dotColGreen =dataArray[16];}
    if(color == 1){ dotColRed =dataArray[16] ;   dotColGreen =dataArray[16-i];}
    if(color == 2){ dotColRed =dataArray[16-i] ; dotColGreen =dataArray[16];}
    if(color == 3){ dotColRed =dataArray[16-i] ; dotColGreen =dataArray[16-i];}}}
  
    digitalWrite(latchPin, 0);
    shiftOut(dataArray[16],dotColRed,dotColGreen);
    digitalWrite(latchPin, 1);
  
 }

 //____________ [ch3649][ch3626][ch3604][ch3591] 4x4
 void fourshow(int myRow,int myCol, int color)
{
    byte dotRow;
    byte dotColRed;
    byte dotColGreen;
   
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3649][ch3606][ch3623][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621] [ch3610][ch3609]-[ch3621][ch3656][ch3634][ch3591]
    if( myRow == 2){dotRow = dataArray[18];}
    if( myRow == 1){dotRow = dataArray[19];}
   
    //[ch3585][ch3635][ch3627][ch3609][ch3604][ch3588][ch3629][ch3621][ch3633][ch3617][ch3649][ch3626][ch3604][ch3591][ch3612][ch3621][ch3588][ch3629][ch3621][ch3633][ch3617] [ch3595][ch3657][ch3634][ch3618]-[ch3586][ch3623][ch3634] + [ch3585][ch3635][ch3627][ch3609][ch3604][ch3626][ch3637]
   
    if(myCol == 1){
    if(color == 0){ dotColRed =dataArray[16] ; dotColGreen =dataArray[16];}
    if(color == 1){ dotColRed =dataArray[16] ; dotColGreen =dataArray[18];}
    if(color == 2){ dotColRed =dataArray[18] ; dotColGreen =dataArray[16];}
    if(color == 3){ dotColRed =dataArray[18] ; dotColGreen =dataArray[18];}}
   
    if(myCol == 2){
    if(color == 0){ dotColRed =dataArray[16] ; dotColGreen =dataArray[16];}
    if(color == 1){ dotColRed =dataArray[19] ;   dotColGreen =dataArray[16];}
    if(color == 2){ dotColRed =dataArray[16] ; dotColGreen =dataArray[19];}
    if(color == 3){ dotColRed =dataArray[19] ; dotColGreen =dataArray[19];}}
  
    digitalWrite(latchPin, 0);
    shiftOut(dotRow,dotColRed,dotColGreen);
    digitalWrite(latchPin, 1);
  
 }



void shiftOut(byte myDataOut,byte myDataOutRed,byte myDataOutGreen) {
  
  int i=0;
 
  
  int pinState;
  int pinStateRed;
  int pinStateGreen;
  
  pinMode(clockPin, OUTPUT);
  
  pinMode(dataPin,OUTPUT);
  pinMode(dataPinRed,OUTPUT);
  pinMode(dataPinGreen,OUTPUT);

  digitalWrite(dataPin, 0);
  digitalWrite(dataPinRed, 0);
  digitalWrite(dataPinGreen, 0);
  
  digitalWrite(clockPin, 0);

  
  for (i=0; i<=7; i++)  {
  digitalWrite(clockPin, 0);
   
    if ( myDataOut  & (1<<i) ) { pinState= 1; } else {pinState = 0;}
    if ( myDataOutRed & (1<<i)) { pinStateRed= 1;} else {pinStateRed= 0;}
    if ( myDataOutGreen & (1<<i) ) { pinStateGreen= 1; } else {pinStateGreen=0;}

    digitalWrite(dataPin, pinState );
    digitalWrite(dataPinRed,  pinStateRed);
    digitalWrite(dataPinGreen, pinStateGreen);
   
    digitalWrite(clockPin, 1);
   
    digitalWrite(dataPin,0);
    digitalWrite(dataPinRed, 0);
    digitalWrite(dataPinGreen, 0);
  
  }
  
  digitalWrite(clockPin, 0);
}

void  myarray(){

  dataArray[0]   = 0x80; //10000000
  dataArray[1]   = 0x40; //01000000
  dataArray[2]   = 0x20; //00100000
  dataArray[3]   = 0x10; //00010000
  dataArray[4]   = 0x08; //00001000
  dataArray[5]   = 0x04; //00000100
  dataArray[6]   = 0x02; //00000010
  dataArray[7]   = 0x01; //00000001
  
  dataArray[8]   = 0x7F; //01111111
  dataArray[9]   = 0xBF; //10111111
  dataArray[10]  = 0xDF; //11011111
  dataArray[11]  = 0xEF; //11101111
  dataArray[12]  = 0xF7; //11110111
  dataArray[13]  = 0xFB; //11111011
  dataArray[14]  = 0xFD; //11111101
  dataArray[15]  = 0xFE; //11111110
  
  dataArray[16]  = 0xFF; //11111111
  dataArray[17]  = 0x00; //00000000
  
  dataArray[18]  = 0xF0; //11110000
  dataArray[19]  = 0x0F; //00001111
  
}



I come from thailand

My English is not good

 :smiley

[ch3655]Hello = " Sa Wat Dee"
Nice to meet you all.






2  Forum 2005-2010 (read only) / Exhibition / 8x8 LED Dot Matrix 2 Color + Freeduino on: April 16, 2010, 02:52:45 pm
  ;D.........

8x8 LED Dot Matrix 2 Color + 74HC595
[media]http://www.youtube.com/watch?v=bfpH72zOINk&feature=player_embedded[/media]






3  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Pong on: April 16, 2010, 01:46:11 pm
Interesting Project...

Thank you ;D
4  Forum 2005-2010 (read only) / Exhibition / Ps2 KeyBoard  TV Remote on: April 17, 2010, 05:25:01 am
[ch3657][ch3657]Hello  ;D

" Sa Wat Dee "

This is my project

Arduino Ps2 KeyBoard  TV Remote
[media]http://www.youtube.com/watch?v=HWORWJsqAjE&feature=player_embedded[/media]










Code:
#include <IRremote.h>
#include <ps2.h>
unsigned char code;

int RECV_PIN = 7;  // [ch3586][ch3634] data [ch3586][ch3629][ch3591][ch3605][ch3633][ch3623][ch3619][ch3633][ch3610][ch3619][ch3637][ch3650][ch3617][ch3607] [ch3605][ch3656][ch3629][ch3585][ch3633][ch3610] digitital pin 7
int RECV_POWER = 2; // [ch3586][ch3634][ch3652][ch3615][ch3610][ch3623][ch3585] [ch3586][ch3629][ch3591][ch3605][ch3633][ch3623][ch3619][ch3633][ch3610][ch3619][ch3637][ch3650][ch3617][ch3607] [ch3605][ch3656][ch3629][ch3585][ch3633][ch3610] digital pin 2

int IR_GND = 1; // [ch3586][ch3634][ch3652][ch3615][ch3621][ch3610][ch3586][ch3629][ch3591][ch3627][ch3621][ch3629][ch3604] ir digital pin 1

int LED_1 = 11;
int LED_2 = 12;
int LED_3 = 13;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

PS2 kbd(5, 4); // Ps2 keyborad  data [ch3605][ch3656][ch3629][ch3585][ch3633][ch3610] digital pin 4
                       // clock [ch3605][ch3656][ch3629][ch3585][ch3633][ch3610] digital pin 5

void kbd_init()
{
  char ack;

  kbd.write(0xff);  // send reset code
  ack = kbd.read();  // byte, kbd does self test
  ack = kbd.read();  // another ack when self test is done
}

void setup()
{
  
   kbd_init();
 
  irrecv.enableIRIn(); // Start the receiver
 
  pinMode(RECV_POWER,OUTPUT);
  digitalWrite(RECV_POWER,LOW);
  
  pinMode(LED_1, OUTPUT);
  digitalWrite(LED_1,HIGH);
  
  pinMode(LED_2,OUTPUT);
  digitalWrite(LED_2,HIGH);
  
  pinMode(LED_3,OUTPUT);
  digitalWrite(LED_3,HIGH);
  
  pinMode(IR_GND,OUTPUT);
  digitalWrite(IR_GND,LOW);
  
  keyBoardCode();
  
 }

// Storage for the recorded code
int codeType = -1; // The type of code
unsigned long codeValue; // The code value if not raw
unsigned int rawCodes[RAWBUF]; // The durations if raw
int codeLen; // The length of the code
int toggle = 0; // The RC5/6 toggle state

//[ch3619][ch3633][ch3610]
unsigned long myValue[80];
int myLen[80];

//[ch3626][ch3656][ch3591]
unsigned long sendIrValue;
int sendIrLen;

unsigned char keyboard[80];

// Stores the code for later playback
// Most of this code is just logging

void storeCode(decode_results *results) {
  codeType = results->decode_type;
  int count = results->rawlen;
 
  if (codeType == UNKNOWN)
  {
    codeLen = results->rawlen - 1;
   
     for (int i = 1; i <= codeLen; i++) {
      if (i % 2) {
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK - MARK_EXCESS;
        delay(1);}
        else {
        rawCodes[i - 1] = results->rawbuf[i]*USECPERTICK + MARK_EXCESS;
        delay(1);}}
   }else {
    if (codeType == NEC) {
    if (results->value == REPEAT) {
        delay(1);
        return;}}  
    else if (codeType == SONY){delay(1);}
    else if (codeType == RC5) {delay(1);}
    else if (codeType == RC6) {delay(1);}
    else {delay(1);}
   
    codeValue = results->value;
    codeLen = results->bits;
  }
}

void sendCode(int repeat) {
  
   // code [ch3627][ch3621][ch3633][ch3585][ch3616][ch3634][ch3588][ch3626][ch3656][ch3591]
  if (codeType == NEC)
  {
    if (repeat) {irsend.sendNEC(REPEAT, sendIrLen);}
    else { irsend.sendNEC(sendIrValue, sendIrLen);}
  }
 
  else if (codeType == SONY){irsend.sendSony(sendIrValue, sendIrLen);}
  
  else if (codeType == RC5 || codeType == RC6)
  {
       if (!repeat) { toggle = 1 - toggle;}
       sendIrValue = sendIrValue & ~(1 << (sendIrLen - 1));
       sendIrValue = sendIrValue | (toggle << (sendIrLen - 1));
       if (codeType == RC5) { irsend.sendRC5(sendIrValue, sendIrLen);}
       else { irsend.sendRC6(sendIrValue, sendIrLen);}
  }
  
  else if (codeType == UNKNOWN ) {irsend.sendRaw(rawCodes, sendIrLen, 38);}
  

}

int lastButtonState;
int buttonState = HIGH;
int recvButton = 1;
int recvState;

int irButton ;
int irState  ;

int test;

void loop() {
  
  
  code = kbd.read();
  
 //keyBoard F1 setup IR
  if(code == 0x05){recvButton = 1-recvButton;
     irrecv.enableIRIn(); // Re-enable receiver  
     if(recvButton==0)recvState = 1-recvState;}

 ///////// [ch3648][ch3611][ch3636][ch3604][ch3611][ch3636][ch3604][ch3585][ch3634][ch3619][ch3607][ch3635][ch3591][ch3634][ch3609] ir recv
  if(recvState == 1){
    digitalWrite(RECV_POWER,HIGH) ;
    digitalWrite(LED_1,LOW);
    digitalWrite(IR_GND,HIGH);
    GotoSetKeyBoard();}//[ch3605][ch3633][ch3657][ch3591][ch3588][ch3656][ch3634][ch3611][ch3640][ch3656][ch3617]
   
  if(recvState == 0){
         digitalWrite(RECV_POWER,LOW) ;
         digitalWrite(LED_1,HIGH);
         digitalWrite(IR_GND,LOW);
         GotoSendIr();} // [ch3626][ch3656][ch3591] code remote
         
         
}



 //////////////[ch3648][ch3585][ch3655][ch3610] Code Remote [ch3605][ch3634][ch3617][ch3611][ch3640][ch3656][ch3617]////////////////////
void GotoSetKeyBoard()
{
 
 for(int i = 0; i < 80;i++){
 if(code == keyboard[i]   ){  
       myValue[i] = codeValue;
       myLen[i] = codeLen;  
      
  }}     
  // [ch3629][ch3656][ch3634][ch3609][ch3588][ch3656][ch3634] Remote
  if (irrecv.decode(&results)) {
    digitalWrite(LED_1, LOW);
    storeCode(&results);
    delay(1);
    irrecv.resume(); // resume receiver
    digitalWrite(LED_1, HIGH);}   
  
 }
 



 ////////////////////// [ch3626][ch3656][ch3591] code remote ////////////////////////////
void GotoSendIr()
{
    /// [ch3585][ch3604][ch3611][ch3640][ch3656][ch3617][ch3626][ch3656][ch3591] Remote
    for(int i = 0; i < 80;i++){
    if(code == keyboard[i]  ){
    irButton = 1-irButton;         
    if(irButton == 0)irState = 1;
   
    sendIrValue = myValue[i];
    sendIrLen   = myLen[i];

   }}
   
   /// [ch3626][ch3656][ch3591][ch3588][ch3656][ch3634] Remote
   if (irState == 1 ) {
    digitalWrite(LED_1, LOW);
    sendCode(LOW);
    digitalWrite(LED_1, HIGH);
    delay(100); // Wait a bit between retransmissions
    irState = 0;}
}

////////////////// keyBoardCode//////////////////
void keyBoardCode()
{
  keyboard[0] = 0x075; // up
  keyboard[1] = 0x072; // down
  keyboard[2] = 0x06B; // left
  keyboard[3] = 0x074; // right
  
  keyboard[4] = 0x070; // lns
  keyboard[5] = 0x071; // Del
  keyboard[6] = 0x06C; // HOME
  keyboard[7] = 0x069; // End
  keyboard[8]  = 0x07D; // P up
  keyboard[9]  = 0x07A; // P down
  
  
  keyboard[10] = 0x16; // 1
  keyboard[11] = 0x1E; // 2
  keyboard[12] = 0x26; // 3
  keyboard[13] = 0x25; // 4
  keyboard[14] = 0x2E; // 5
  keyboard[15] = 0x36; // 6
  keyboard[16] = 0x3D; // 7
  keyboard[17] = 0x3E; // 8
  keyboard[18] = 0x46; // 9
  keyboard[19] = 0x45; // 0
  keyboard[20] = 0x4E; // -
  keyboard[21] = 0x55; // +
  keyboard[22] = 0x66; // back
  keyboard[23] = 0x0E; // ~
  
 }


5  Forum 2005-2010 (read only) / Exhibition / Program Speech recognition +  Light  Control on: April 16, 2010, 02:00:52 pm

Hello..... ;D

"Sa wat Dee"



I come form thailand

My English is not good   smiley-razz

This is  my project


[size=14]Computer => Arduino  => Relay  => Lighting Control[/size]


Program
Voice Flux Pro = Program  Speech recognition
http://nitrous-voice-flux.en.softonic.com/

Hardware
- Freeduino
- Relay shield
- light bulb
- computer



Vdo

[media]http://www.youtube.com/watch?v=OeDBsk5_yEc&feature=player_embedded[/media]


Freeduino + Relay shield

http://i978.photobucket.com/albums/ae268/sodanum_photo/100_2903.jpg


more detail (Thai language)

http://www.electoday.com/bbs/viewthread.php?tid=5210



Arduino
Code:
// Relay digital pin 7,4
int relayOne = 4;
int relayTwo = 7;

void setup()   {   

  Serial.begin(9600);
  pinMode(relayOne, OUTPUT);  
  pinMode(relayTwo, OUTPUT);   
  
}

void loop()                     
{
  
  char c;
  
  if (Serial.available())
  {
    c = Serial.read();
    if(c == 'a'){digitalWrite(relayOne, HIGH);}
    if(c == 's'){digitalWrite(relayOne, LOW);}
   
    if(c == 'z'){digitalWrite(relayTwo, HIGH);}
    if(c == 'x'){digitalWrite(relayTwo, LOW);}
   }
  
}


Processing
Code:
import processing.serial.*;

Serial myPort;  
      

void setup()
{
 
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
}

void draw() {
  background(255);
  if(keyPressed) {
     if(key >= 'A' && key <= 'z') {
       if(key == 'a') myPort.write('a');            
       if(key == 's') myPort.write('s');           
     }
  }
      
}
Pages: [1]