Show Posts
Pages: 1 2 [3] 4 5 ... 12
31  Forum 2005-2010 (read only) / Interfacing / Re: High-power LED problem on: January 26, 2010, 04:09:25 pm
I think I have worse news. I have the circuit set up with 3.3V regulators (4 of them, two paired with two LEDs each, in parallel), remember. So, visualize this: 3.3V regulator--->LED--->2N2222--->GND (transistor is sinking the current). The LEDs currently have no resistors on them. I think I have gotten lucky with not 'over-currenting' them thus far.
32  Forum 2005-2010 (read only) / Interfacing / Re: High-power LED problem on: January 26, 2010, 03:53:59 pm
Thanks for the reply. Take a look at this thread:
http://forums.parallax.com/forums/?f=5&m=421529&g=421577#m421577

The LEDs that are doubled up with a voltage regulator are in parallel. I'm not sure if that matters at this point though.

It looks like the voltage drop of the 2N2222's is approx. 1V in this case, and the forward voltage of the each LED is ~3.4V-3.99V. This goes at least 1V above the voltage regulator's output. Can you help answer my last question on that forum? Thank you!!
33  Forum 2005-2010 (read only) / Interfacing / High-power LED problem on: January 26, 2010, 02:13:08 pm
This was originally posted in THIS forum.

Alright. I have read this forum and I understand it, relatively. I have a similar problem of my own, and I need to solve it *quickly* for a robotics club event. Using an Arduino Pro (ATmega328) I am driving six 1-Watt green Luxeon LEDs, using a 2N2222 NPN for each. I have 4 LD1117V33 3.3V regulators  (supposedly rated at 800mA), two driving just one LED, and the other two driving two LEDs each. As I analyze the transistors I've used, I think I made a silly mistake, maybe? The problem is: the LEDs are not running at full brightness based on lumen output (I can tell). These are also rated for 350mA each. When I drive them with 50% PWM, they are fine. But when I turn them completely on, something weird happens. They shine extremely bright for about 1/2 sec, then they go very dim, and stay that way until I reset the Arduino. To test if this is a brownout issue in the AVR chip, I set the code to keep an LED lit (pin 13) when running; when this issue happens, the LED does not flicker. Another tip: I forgot (bad, I know) to add 1W resistors (10-Ohm in this case would be necessary) from the output of the 3.3V regs to the LEDs. I have 1k-ohm resistors going from the arduino's PWM outputs to the 2N2222 switching transistors. What is going on and how can I fix it? I tried to gain an understanding for what could be happening by reading this post, but I think I still need some help.

Thanks in advance   smiley
34  Forum 2005-2010 (read only) / Exhibition / Arduino to iRobot Roomba/Create on: September 21, 2009, 07:35:24 pm
I have been working on a project over the summer and I had to add functionality to Todd E. Kurt's (author of "Hacking Roomba") code; I added in functionality to include ALL the sensor readings, and (rudimentary, but effective) error checking for serial data packets.

Here's the code that handles all serial communication with the Roomba/Create:

Code:
char sensorbytes[10];

// Sensor Packet 1
#define BUMPRIGHT (sensorbytes[0] & 0x01)  
#define BUMPLEFT  ((sensorbytes[0] & (1<<1))>>1)
#define WHEELDROP_C ((sensorbytes[0] & (1<<4))>>4)  
#define WHEELDROP_L ((sensorbytes[0] & (1<<3))>>3)
#define WHEELDROP_R ((sensorbytes[0] & (1<<2))>>2)
#define WALL (sensorbytes[1])
#define CLIFF_L (sensorbytes[2])
#define CLIFF_FL (sensorbytes[3])
#define CLIFF_FR (sensorbytes[4])
#define CLIFF_R (sensorbytes[5])
#define VWALL (sensorbytes[6])
#define MOTOROVER_L ((sensorbytes[7] & (1<<4))>>4)
#define MOTOROVER_R ((sensorbytes[7] & (1<<3))>>3)
#define DIRT_L (sensorbytes[8])
#define DIRT_R (sensorbytes[9])

// Sensor packet 2
#define REMOTE (sensorbytes[0])
#define BUTTON_CLEAN ((sensorbytes[1] & (1<<1))>>1)
#define BUTTON_SPOT ((sensorbytes[1] & (1<<2))>>2)
#define BUTTON_POWER ((sensorbytes[1] & (1<<3))>>3)
#define DISTANCE ((sensorbytes[2] << 8) +  sensorbytes[3])
#define ANGLE ((360*((sensorbytes[4] << 8) + sensorbytes[5]))/(258*PI))   // Degrees
#define RADIANS ((2 * ((sensorbytes[4] << 8) + sensorbytes[5])) / 258)    // Radians

// Sensor Packet 3
#define CHARGE_STATE (sensorbytes[0])
#define VOLTAGE ((sensorbytes[1] << 8) + sensorbytes[2])
#define CURRENT ((sensorbytes[3] << 8) + sensorbytes[4])
#define TEMP (sensorbytes[5])
#define CHARGE ((sensorbytes[6] << 8) + sensorbytes[7])
#define CAPACITY ((sensorbytes[8] << 8) + sensorbytes[9])

...

void updateSensors(byte packet) {
  Serial.print(142, BYTE);
  Serial.print(packet, BYTE);  
  delay(100); // wait for sensors
  char i = 0;
  
  while(Serial.available()) {
    int c = Serial.read();
    if( c==-1 ) {
      SensorError();
    }
    sensorbytes[i++] = c;
  }
  
  if(i < 6) {     // Size of smallest sensor packet is 6
    SensorError();
  }
}
void SensorError() {
  for(byte i = 0; i < 10; i++) {
    digitalWrite(ledPin, HIGH);
    delay(25);
    digitalWrite(ledPin, LOW);
    delay(25);
  }
  delay(500);
}

void WakeUp() {
  // wake up the robot
  digitalWrite(ddPin, LOW);
  delay(100);
  digitalWrite(ddPin, HIGH);
  delay(2000);
}

The '...' indicates I've left out all the other stuff (required loop(), setup(), etc). This is just the stuff you'll need in addition to your code.

In the void setup(){} function, you can put this to control the roomba:

Code:

  WakeUp();
  
  for(i = 0; i < 3; i++) {     // Set baud rate to 19200bps
    digitalWrite(ddPin, LOW);
    delay(100);
    digitalWrite(ddPin, HIGH);
    delay(100);
  }
  
  Serial.begin(19200);
  delay(100);
  
  // set up ROI to receive commands  
  Serial.print(128, BYTE);  // START (Now in PASSIVE Mode)
  delay(50);

  Serial.print(133, BYTE);  // POWER; Turn off to see if we are plugged in
  delay(100);
  ChargeMonitor();
  
  Serial.print(130, BYTE);  // CONTROL (Now in SAFE Mode)
  delay(50);


In the 'ChargeMonitor' routine, I added some code to use alongside an Emic TTS module to speak out charging/battery status, but the code doesn't seem to work (somehow I'm sending the data to it improperly...). I used the SoftSerial library to communicate with the Emic.

Also, a milestone that, according to my online searches, close to nobody knows:

In order to communicate to the roomba, the ATmegaxxx MUST be disconnected from the Tx/Rx pins of the FT232 USB-Serial chip. The FT232 seems to drop the voltage coming from the roomba/from the arduino to the roomba, and therefore voltage trigger thresholds (HI/LO) are out of whack for serial communication, and it almost always doesn't work.

Have fun!
35  Forum 2005-2010 (read only) / Exhibition / Re: Arduino Pong on: March 22, 2008, 03:08:09 pm
Wow. That's extremely impressive!!!   :o
GREAT Work!
36  Forum 2005-2010 (read only) / Exhibition / Re: ArduDreamer on: March 11, 2010, 03:52:45 pm
I have to say, this is a superb project. Probably the coolest application I have ever seen with the Arduino. I would be more than willing to assemble this circuit and make a nice finished product (if all the schematics are all in place...), giving you credit for the design. Very, very cool  8-)
37  Forum 2005-2010 (read only) / Exhibition / Re: Touchpad Midi on: September 23, 2009, 03:22:25 pm
Yup. My assumptions were correct!
38  Forum 2005-2010 (read only) / Exhibition / Re: Touchpad Midi on: September 20, 2009, 10:12:53 pm
My sneaking suspicion is that the pin right next to GND is +5V...maybe
39  Forum 2005-2010 (read only) / Exhibition / Re: Touchpad Midi on: September 20, 2009, 10:11:16 pm
Alright. I've got a Synaptics touchpad here out of a Dell Inspiron 1100, and I'm not sure which pins are the SDA/SCL pins...There are 6 pins - 1 I have found is GROUND, two are for the buttons ('B1' and 'B2'), and the rest must be SDA, SCL, and +5V. Can anyone help me out here as to what is what? Thanks!

40  Forum 2005-2010 (read only) / Exhibition / MIDI Controller/Sequencer with Touchpad Interface on: October 11, 2009, 11:34:45 pm
A while back, I saw this post here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1197235191, and I was so impressed and inspired, that I decided that I'd make my own! My version isn't quite as polished, but it is pretty close. I have added MIDI IN on my version, but it has been tremendously difficult to get that to work in software thus far, even with the MIDI libraries some have made!

I took a touchpad from an old Dell Inspiron 1100 laptop, traced the PCB connections, and implemented it with a surprisingly little amount of trouble. I added a single potentiometer, a tri-color ('RGB') LED, DPDT switch to add ease of programming (switches serial connections so MIDI interface does not interfere with FT232 USB->Serial programming/debugging interface).

It also has a MIDI IN and OUT jacks, and a large rocker power switch with a simple but very effective power circuit that uses a transistor NOT gate (made with a single BC548B NPN transistor), and a TIP120 power transistor among a few other components. This circuit is necessary to protect the 5V USB and regulated 5V voltages from doubling up and damaging things if the system is connected to a USB port and external power source (i.e. wall tansformer, battery pack) at the same time.

I attempted this a while back, but I made it so complex that it became impossible to debug and develop any further, and I abandoned it. So I took a different approach this time and kept things simple (sortof), and I've made all the parts modular so it is easier to work with.

I have yet to make some more I/O functionality; I plan to add multiple (probably 8 or 16) potentiometers with accompanying LEDs and pushbuttons for each, to make it a MIDI sequencer.

Here are some pictures:

http://www.flickr.com/photos/7507189@N04/4003899220/
http://www.flickr.com/photos/7507189@N04/4003133525/
http://www.flickr.com/photos/7507189@N04/4003130423/
http://www.flickr.com/photos/7507189@N04/4003126825/
http://www.flickr.com/photos/7507189@N04/4003140249/
http://www.flickr.com/photos/7507189@N04/4003143431/
41  Forum 2005-2010 (read only) / Exhibition / Re: Midi Audio mixer on: January 28, 2009, 07:26:41 pm
Hey, RIT! I'm in Rochester; that's where I plan on going! Electrical engineering and computer science.
42  Forum 2005-2010 (read only) / Exhibition / Re: Handheld LED-Based Game on: January 30, 2009, 08:08:12 pm
...and the remaining 1/4:

Code:
//This function uses that fact that each bit in a byte
//is 2 times greater than the one before it to
//shift the bits higher
void lightShiftPinB(int p) {

  //start with the pin = 1 so that if 0 is passed to this
  //function pin 0 will light.
  pin = 1;

  for (int x = 0; x < p; x++) {
    pin = pin * 2;
  }
  //move 'em out
  shiftOut(dataPin, clockPin, pin);  
}

void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first,
  //on the rising edge of the clock,
  //clock idles low

  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);

  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);

  //for each bit in the byte myDataOut?
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights.
  for (i=7; i>=0; i--)  {
    digitalWrite(myClockPin, 0);

    //if the value passed to myDataOut and a bitmask result
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000
    // and proceeds to set pinState to 1.
    if ( myDataOut & (1<<i) ) {
      pinState= 1;
    }
    else {      
      pinState= 0;
    }

    //Sets the pin to HIGH or LOW depending on pinState
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin  
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }

  //stop shifting
  digitalWrite(myClockPin, 0);
}
//blinks both registers based on the number of times you want to
//blink "n" and the pause between them "d"
//starts with a moment of darkness to make sure the first blink
//has its full visual effect.
void blinkAll_2Bytes(int n, int d) {
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
  delay(200);
  for (int x = 0; x < n; x++) {
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 255);
    digitalWrite(latchPin, 1);
    delay(d);
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 0);
    shiftOut(dataPin, clockPin, 0);
    digitalWrite(latchPin, 1);
    delay(d);
  }
}
void Clear() {
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
}
void Win() {

}
void DIAGNOSTICS() {
  for(i = 0; i < 15; i++) {
    digitalWrite(13, HIGH);
    delay(50);
    digitalWrite(13, LOW);
    delay(50);
  }
  delay(100);
  blinkAll_2Bytes(2,500);
  delay(500);
  digitalWrite(rdPin, HIGH);
  delay(1000);
  digitalWrite(rdPin, LOW);
  delay(1000);
  digitalWrite(gnPin, HIGH);
  delay(1000);
  digitalWrite(gnPin, LOW);
  delay(100);
  digitalWrite(blPin, HIGH);
  delay(100);
  digitalWrite(blPin, LOW);
  delay(100);
  End();
}

And here's the BASIC Stamp II code:

Code:
' {$STAMP BS2e}
' {$PBASIC 2.5}

OK      PIN  0
Pzo     PIN  7
LCD     PIN  8
READY   PIN  13
ATX     PIN  15

' -----[LCD Commands]----------------------
' CMD followed by:
' -128 - 143 (Line 1), 144 - 159 (Line 2) = Set Cursor Position
' -ASCII letters 'K'-'P' = Set baud to 2.4K, 4.8K, 9.6K, 14.4K, 19.2K, and 38.4K bps respectively
CMD     CON  $FE   ' COMMAND Instruction
CLLCD   CON  $01   ' Clear LCD
CURR    CON  $14   ' Cursor Right
CURL    CON  $10   ' Cursor Left
SCR     CON  $1C   ' Scroll Right
SCL     CON  $18   ' Scroll Left
DON     CON  $0C   ' Display ON
DOFF    CON  $08   ' Display OFF
BBRT    CON  $7C   ' Backlight Brightness (PWM)

BTURBO  CON  6
TMOUT   CON  10000 ' Serial timeout
B       CON  $54   ' 9600 Bps

Yes     CON  1
No      CON  0

i       VAR  Word

id      VAR  Word
datta   VAR  Word

p       VAR  Word

LOW 9
LOW 10
LOW 11

'OUTPUT READY
INPUT READY
LOW READY

IF IN6 = 0 THEN
  HIGH 11
  SERIN ATX\READY,BTURBO,TMOUT,Serial_Error,[id]    ' OK is LOW when ready for data
  GOSUB DIAGNOSTICS
ENDIF

SEROUT 8, B, [CMD, CLLCD]
PAUSE 4000
SEROUT 8, B, [CMD, 131, "Welcome to"]
PAUSE 1000
SEROUT 8, B, [CMD, CLLCD]
PAUSE 100
SEROUT 8, B, [CMD, 131, "Lightning         Reflex!!"]
PAUSE 2000
FOR i = 1 TO 14
  SEROUT 8, B, [CMD, SCL]
  PAUSE 100
NEXT

Main:
DO
  DEBUG CR, "Main"

  GOSUB Get_Data
  GOSUB Determine_Operation

LOOP

Get_Data:

DEBUG CR,"Getting data..."
SERIN ATX\READY,BTURBO,TMOUT,Serial_Error,[id]    ' OK is LOW when ready for data
PAUSE 1
SERIN ATX\READY,BTURBO,TMOUT,Serial_Error,[datta] ' OK is LOW when ready for data
'DEBUG CR,id, CR, DEC datta
RETURN

Serial_Error:
  DEBUG CR,"Serial timeout."
  GOTO Main

Determine_Operation:

DEBUG CR, "Determine Operation"

SELECT id
  CASE "B":
    DEBUG CR, "Buttons"
    GOSUB Read_Buttons
ENDSELECT
RETURN

Read_Buttons:

DEBUG CR, "Reading Buttons"

  IF IN6 = 0 THEN
    HIGH 11            ' Select Button
    DO
      PAUSE 1
    LOOP WHILE READY = 0
    LOW 11
    GOTO Main
  ENDIF

  IF IN5 = 0 THEN        ' Left Button
    HIGH 9
    DO
      PAUSE 1
    LOOP WHILE READY = 0
    LOW 9
    GOTO Main
  ENDIF

  IF IN4 = 0 THEN        ' Right Button
    HIGH 10
    DO
      PAUSE 1
    LOOP WHILE READY = 0
    LOW 10
    GOTO Main
  ENDIF
GOTO Read_Buttons

DIAGNOSTICS:

PAUSE 2000
DEBUG CR, "DIAGNOSTICS MODE"
SEROUT 8, B, [CMD, CLLCD]
SEROUT 8, B, ["DIAGNOSTICS MODE"]
END
43  Forum 2005-2010 (read only) / Exhibition / Re: Handheld LED-Based Game on: January 30, 2009, 08:06:17 pm
I can post the code for both microcontrollers thus far (but they are a MESS!) if it would help...? Note that they are in 'debug' condition; I have code snippets in places they normally wouldn't be, for debugging.

Here's 3/4 of the Arduino code:

Code:
/*
NOTES: Shift Register 1 (MAIN):
       Q2: Bottom Left MEM LED
       Q3: Top Left MEM LED
        
       Shift Register 2:
       Q0:
       Q1:
       Q2:
       Q3:
       Q4:
       Q5:
       Q6: Top Right MEM LED
       Q7: Bottom Right MEM LED
*/
int LButton = 6;
int RButton = 7;
int SButton = 5;
int OKAY = 8;
int READY = 1;  // (Analog)

boolean Lval; //l
boolean Rval; //r
boolean Sval;  //s
boolean OKAYval;

int clockPin = 2; // Digital 9 ; SH_CP on Shift Register      
int latchPin = 4; // Digital 10 ; ST_CP on Shift Register  
int dataPin = 3;    // Digital 11 ; DATA on Shift register  
int gnPin = 9;    // Digital (PWM) 9 ; Blue RGB LED
int blPin = 10;    // Digital (PWM) 10 ; Red RGB LED
int rdPin = 11;    // Digital (PWM) 11 ; Green RGB LED

int pin;

int D;     // Delay Time

byte j;    // Reflex/Memory LED # (0 - 7)
byte M;    // Memory LED # (2 - 3)

int i;     // Generic Counter

boolean runthru;
boolean middle;

boolean OK;

byte dataMem;                // 'Memory' LED bank
byte dataRef;                // 'Reflex' LED bank
byte dataArrayMem[2];
byte dataArrayRef[8];

char ID;
byte CMD;

char BUTTON = 'B';
char SOUND = 'S';
char CONFIRM = 'K';

void setup() {
  Serial.begin(9600);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  digitalWrite(11, HIGH);
  digitalWrite(12, LOW);
  End();
  
  // The following arrays are for lighting ONE LED at a time
  dataArrayMem[0] = B00000010;
  dataArrayMem[1] = B00000011;
 
  dataArrayRef[0] = B00000000;
  dataArrayRef[1] = B00000001;
  dataArrayRef[2] = B00000010;
  dataArrayRef[3] = B00000011;
  dataArrayRef[4] = B00000100;
  dataArrayRef[5] = B00000101;
  dataArrayRef[6] = B00000110;
  dataArrayRef[7] = B00000111;

  pinMode(latchPin, OUTPUT);
  pinMode(blPin, OUTPUT);
  pinMode(rdPin, OUTPUT);
  pinMode(gnPin, OUTPUT);
  pinMode(LButton, INPUT);
  pinMode(RButton, INPUT);
  pinMode(SButton, INPUT);
  
  Clear();
  delay(200);
  
  Sval = digitalRead(SButton);
  if(Sval == 1) {                // User can enter diagnostics mode by
    Serial.begin(38400);
    OK = analogRead(READY);
    while(OK == HIGH) {
      OK = analogRead(READY);
      delayMicroseconds(1);
    }
    while(OK == LOW) {
      OK = analogRead(READY);
      Serial.println(ID);
    }
  }
}
void loop() {
  dataRef = B111111;    // Just the top row ('Refex' LED's)
  dataMem = 0;
  WriteArray();
  Menu();
}
void Menu() {
  ID = BUTTON;
  CMD = 1;
  SendData();
  Sens();
  if(Lval || Rval) {
    Lval = 0;
    Rval = 0;
    if(dataRef == B111111) {
      dataRef = B11000000;
      dataMem = B00001100;
      WriteArray();
      delay(500);
    }
    else {
      dataRef = B111111;
      dataMem = 0;
      WriteArray();
      delay(500);
    }
  }
  if(Sval) {
    Sval = 0;
    if(dataRef == B111111) {
      for(i = 0; i < 5; i++) {
        dataRef = 0;
        WriteArray();
        delay(50);
        dataRef = B111111;
        WriteArray();
        delay(50);
      }
      RefSplash();
      LightningReflex();
    }
    else {
      for(i = 0; i < 5; i++) {
        dataRef = 0;
        dataMem = 0;
        WriteArray();
        delay(50);
        dataRef = B11000000;
        dataMem = B00001100;
        WriteArray();
        delay(50);
      }
    }
  }
  Menu();  
}
void LightningReflex() {
  D = 50;
  // light each pin one by one using a function A
  for (int j = 5; j > -1; j--) {
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    // Reflex Game LEDs
    lightShiftPinA(j);
    // Memory Game LEDs
    lightShiftPinA(0);
    //return the latch pin high to signal chip that it
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    delay(D);
    Check();
    if(j == 3) {
      Middle();
    }
  }

  // light each pin one by one using a function A
  for (int j = 0; j < 6; j++) {
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    //red LEDs
    lightShiftPinB(j);
    //green LEDs
    lightShiftPinB(0);
    //return the latch pin high to signal chip that it
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    delay(D);
    Check();
    if(j == 2) {
      Middle();
    }
  }
  LightningReflex();
}
void Check() {
  Sens();
  if(Sval == 1) {
    if(middle == true) {
      middle = false;
      Win();
    }
    if(middle == false) {
      Sval = 0;
      switch(pin) {
        case 0:
          dataRef = B10000000;
        case 1:
          dataRef = B01000000;
        case 2:
          dataRef = B00100000;
        case 3:
          dataRef = B00010000;
        case 4:
          dataRef = B00001000;
        case 5:
          dataRef = B00000100;
      }
      for(i = 0; i < 5; i++) {
        WriteArray();
        delay(50);
        dataRef = 0;
        WriteArray();
        delay(50);
      }  
    }
  }
}
void Middle() {
  middle = true;
  runthru = !runthru;
  switch(runthru) {
    case 0:
      analogWrite(rdPin, 50);
      break;
    case 1:
      analogWrite(gnPin, 50);
      break;
  }
  delay(D);
  digitalWrite(gnPin, LOW);
  digitalWrite(rdPin, LOW);
  Check();
}
void End() {
  delay(500);
  End();
}
void Sens() {                   // Read all sensors (button states from BS2)
  digitalWrite(13, HIGH);
  //pinMode(OKAY, OUTPUT);
  //digitalWrite(OKAY, LOW);
  Lval = digitalRead(LButton);
  Rval = digitalRead(RButton);
  Sval = digitalRead(SButton);
  if(Lval == 1) {
    digitalWrite(rdPin, HIGH);
    delay(5000);
    analogWrite(READY, HIGH);
  }
  if(Rval == 1) {
    digitalWrite(gnPin, HIGH);
    delay(5000);
    analogWrite(READY, HIGH);
  }
  if(Sval == 1) {
    digitalWrite(blPin, HIGH);
    delay(5000);
    analogWrite(READY, HIGH);
  }
  delay(100);
  analogWrite(READY, LOW);
  analogWrite(13, LOW);
}
void SendData() {
  //digitalWrite(OKAY, LOW);
  Serial.begin(38400);
  OK = analogRead(READY);
  while(OK == HIGH) {
    OK = analogRead(READY);
    delayMicroseconds(1);
  }
  while(OK == LOW) {
    OK = analogRead(READY);
    Serial.println(ID);
  }
  while(OK == HIGH) {
    OK = analogRead(READY);
    delayMicroseconds(1);
  }
  while(OK == LOW) {
    OK = analogRead(READY);
    Serial.println(CMD, BYTE);
  }
}
void LightLEDS() {
  //ground latchPin and hold low for as long as you are transmitting
  digitalWrite(latchPin, 0);
  //Reflex Row/Memory Block
  lightShiftPinA(j); // 'Travel' Left: 5-j, 'Travel' Right: j
  //Memory Block
  lightShiftPinA(M);  
  //return the latch pin high to signal chip that it
  //no longer needs to listen for information
  digitalWrite(latchPin, 1);
  delay(D);
}
void WriteArray() {
  //load the light sequence you want from array
  //ground latchPin and hold low for as long as you are transmitting
  digitalWrite(latchPin, 0);
  //move 'em out
  shiftOut(dataPin, clockPin, dataRef);  
  shiftOut(dataPin, clockPin, dataMem);
  //return the latch pin high to signal chip that it
  //no longer needs to listen for information
  digitalWrite(latchPin, 1);
  //delay(300);
}
void MemSplash() {
  D = 100;
  for(i = 0; i < 10; i++) {
    for(j = 6; j < 8; j++) {
      M = 0;
      LightLEDS();
    }
    Clear();
    for(M = 2; M < 4; M++) {
      LightLEDS();
    }
    D = D - 10;
  }
  Clear();
}
void RefSplash() {
  dataMem = 0;
  dataRef = B100001;
  WriteArray();
  delay(250);
  dataRef = B010010;
  WriteArray();
  delay(250);
  dataRef = B001100;
  WriteArray();
  delay(250);
  dataRef = 0;
  WriteArray();
  for(i = 0; i < 125; i++) {
    analogWrite(blPin, i);
    analogWrite(gnPin, i);
    analogWrite(rdPin, i);
    delayMicroseconds(2000);
  }
  delay(500);
  digitalWrite(blPin, 0);
  digitalWrite(rdPin, 0);
  digitalWrite(gnPin, 0);
}
//This function uses bitwise math to move the pins up
void lightShiftPinA(int p) {

  //this is line uses a bitwise operator
  //shifting a bit left using << is the same
  //as multiplying the decimal number by two.
  pin = 1<< p;

  //move 'em out
  shiftOut(dataPin, clockPin, pin);  

}
44  Forum 2005-2010 (read only) / Exhibition / Re: Handheld LED-Based Game on: January 30, 2009, 07:56:28 pm
Okay -

HIGH is around ~4.42V when hooked up to a red LED, ~4.72V with no load

LOW is like 9mV (hooked up to nothing), practically 0V.
45  Forum 2005-2010 (read only) / Exhibition / Re: Handheld LED-Based Game on: January 30, 2009, 07:36:54 pm
Sure...but what do you mean by 'static'??
Pages: 1 2 [3] 4 5 ... 12