Show Posts
Pages: 1 2 [3] 4 5 ... 35
31  Forum 2005-2010 (read only) / Syntax & Programs / Re: sparkfun button pads... again... on: February 16, 2009, 12:00:36 am
oh, very sorry, the part:

http://www.sparkfun.com/commerce/product_info.php?products_id=8033

that's the pcb, and it's in a scanning style... i so wish it wasent, but if it wasent i would have 16 connections, compared to 8... i don't get how to make a good matrix scanning code, while controlling color's of lights, or sending data via serial or whichever protocol... i'm just so confused... let's just try and make a button code first,, ill worry about implementing my light code later...

thanks!
32  Forum 2005-2010 (read only) / Syntax & Programs / sparkfun button pads... again... on: February 11, 2009, 08:58:18 pm
can anybody possibly help me make a good code for scanning the buttons on a sparkfun button pad ( 4x4 pad ). I'm not 100% sure of how a pro might achieve this, but i'm thinking if somebody gives me a base code or an idea of how to make my code, i can continue on their method.

Any help is welcome... i would love to get this 1.5 year old project off the ground finally...

thanks
33  Forum 2005-2010 (read only) / Syntax & Programs / Re: String + integer  - Sorry for this on: January 24, 2008, 11:47:36 pm
he's right, thats what i do....
34  Forum 2005-2010 (read only) / Syntax & Programs / Re: Rgb buttons code on: June 12, 2008, 01:40:39 pm
this is just programing for an rgb button pad sold by spark fun. Originally started from the project a.squar made.

i'm using arduino dual core, but don't worry about that.

lets just say for now i'm using one regular arduino to power half of the button pad since it has 6 pwm ports, and the button pad has 6 connections that power half the board. So all i'm trying to achieve is powering the board, and running the lights every .01 seconds so i can change the colors, since if the grounds all connected at the same time, the whole row would light up the color i turned on.


35  Forum 2005-2010 (read only) / Syntax & Programs / Re: Rgb buttons code on: June 08, 2008, 09:30:51 pm
anybody?
36  Forum 2005-2010 (read only) / Syntax & Programs / Re: Rgb buttons code on: June 07, 2008, 09:34:49 am
here is the new code which does the exact same thing, but i set the pwm pins as outputs like it sais to do in the reference, but it still does the same thing...

Code:
int delay1 = 1;

void setup(){
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(3, OUTPUT);
}
void loop()
{

delay(delay1);
digitalWrite(2, LOW);

analogWrite(3, 255);

delay(delay1);
analogWrite(3, 0);
digitalWrite(2, HIGH);
digitalWrite(4, LOW);

delay(delay1);

digitalWrite(4, HIGH);
digitalWrite(7, LOW);

delay(delay1);

digitalWrite(7, HIGH);
digitalWrite(8, LOW);

delay(delay1);

digitalWrite(8, HIGH);
}

and i did notice that when i slowed down the speed to one second intervals, only one button lit up. This might proove one of 2 things:

1. I'm lacking of arduino coding knowledge, and just screwed up my code somehow...
or 2. arduino is incapable of handling these kinds of speeds and changes so quickly, so the light from one button also gets sent to others...


oh yes, and i refer to analogwrite(3, 255) and then to analogwrite(3, 0) becuase 255 turns it on, and then i have to turn it off before it goes to the next button.
37  Forum 2005-2010 (read only) / Syntax & Programs / Re: Rgb buttons code on: June 07, 2008, 09:22:57 am
sorry, i meant by "bleed off" that it doesent stay on one buttons, when i set delay 1 one, so it's faster then the human eye can see, it can be seen on 3 buttons, when it's only sapposed to be seen on one. Is it maybe arduino that's incapable of operating that fast? also on 2 of the 3 buttons where you can see the light on, there is a dimming affect, and the other button has the opposite, and then a middle button just stay constantly on.

my code try's to turn rows of ground wires off and on so that i can light each individual lights. Thats why you see me delaying by one, then switching 2 digital output's. and then where there is one digital output, i putt in a pwm for full on, and turn it off in the next delay, so it turns on for one button.

do you understand the problem and my code? i'm kind of new to writing codes, so i can only write codes that are basic...

38  Forum 2005-2010 (read only) / Syntax & Programs / Re: Rgb buttons code on: June 06, 2008, 11:39:22 pm
for now they are just lights on buttons, once i get the lights working, ill get the actual button part working.

so here is my first try at a code for this:


Code:

void setup(){
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
}
void loop()
{

delay(10);
digitalWrite(2, LOW);

analogWrite(3, 255);

delay(10);
analogWrite(3, 0);
digitalWrite(2, HIGH);
digitalWrite(4, LOW);

delay(10);

digitalWrite(4, HIGH);
digitalWrite(7, LOW);

delay(10);

digitalWrite(7, HIGH);
digitalWrite(8, LOW);

delay(10);

digitalWrite(8, HIGH);
}


i put delay(10) becuase i wanted to debug, becuase when i set it to 1, it's sapposed to just turn one light on, but it looks like it" bleeds" off to the next two buttons, for no particular reason. do you know why it runs on to the other lights?
39  Forum 2005-2010 (read only) / Syntax & Programs / Rgb buttons code on: June 06, 2008, 08:53:06 pm
i'm working on an rgb button grid ( the sparkfun one ) and i can't figure out a neat way to make my code. The situation is that i'm using arduino dual core ( in the exibition ) but thats besides the point, if i can just get half the board working, together other half can work fine as well.

The only idea i get is that i make delays, and inbetween delays i change the ground pin, and make color changes through pwm. Id there a pwm friendly way tio setup a grid where i can have alot of room to work with and add code and such?

A.squars code is WAY too complicated. I don't know how he achieved the outcome, but he did it very well! if i understood his code, i might be able to work with it, but i can bairly understand anything in his code!

thanks for any help!
40  Forum 2005-2010 (read only) / Syntax & Programs / Re: desired result not being achieved with button on: April 06, 2008, 09:22:41 pm
i'm not sure what your getting at...

do you mean just make a section for their own delays in the code?
41  Forum 2005-2010 (read only) / Syntax & Programs / Re: desired result not being achieved with button on: April 02, 2008, 10:00:41 pm
thats the problem, in my code, the whole code is running at at about 12 ms at the most, and i can't make a seprate timer for the buttons ( or can i and i just don't know about it? )

cuz i change things very fast, if u see i made it 1 ms ( or it may look like 100 cuz i was debugin at only 100 ms...)

i might have to use that dual core arduino from the exhibition to make this simpler, but then again, ill keep trying till theres no more trying...

42  Forum 2005-2010 (read only) / Syntax & Programs / Re: desired result not being achieved with button on: April 02, 2008, 08:39:28 pm
yeppers, i don't have the exact values on hand, but i have, so here are the colors:

brown black orange resistor connected to ground
connected to the brown black orange is both the button output, and a brown black brown resistor, which is connected to the pin.
43  Forum 2005-2010 (read only) / Syntax & Programs / Re: desired result not being achieved with button on: April 02, 2008, 05:16:35 pm
when i mean scanning, i mean that each row is turned on, and then a column is checked for a press, there isint any checking until i write an if statement, but when you see me write digitalWrite(0, HIGH) for pins 0 - 3 ( now changed to pins 8,9,3,4 becuase of problems ) that's what's going on, i'm sending each row a 5v, and then if i wanted to check for a button press, i thought i could make an if staement anywhere saying if pin 2 ( the output 5v button pin ) and pin 16 ( an incoming button pin ) both equal true, then a certain button is being pressed...

this whole row, column thing is a good idea from a looking point, but from a building pint, this just seems so stupid and unecessary... ( even though, when i get this wroking, i would have saved myself 8 pins...

so i gotta make this work, cuz theres no other way unfortunitly
44  Forum 2005-2010 (read only) / Syntax & Programs / Re: desired result not being achieved with button on: April 01, 2008, 09:18:27 pm
oh... i thought it was in setup already, ill move dat now.

but my main problem is that i don't undertsand how to make this work...

heres is my understanding:
i am sapposed to scan through the buttons, like row 1, on row, then row 1 off, row 2 on, then keep going in an infinite circle... and then i check the columns for presses. right?

but when i hooked it up, and held down the buttons, i never recieved "0 0 0 1 0 0 0 1" i always either got  "1 1 1 1 1 1" or a random values like "0 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 0 0 0 "

is that becuase the if statement has to be in a certain place? and inside the if statement, i have to check for both the output pin, and the input pin to be on for the buttons to be true? right? i'm just so confused, i might just have to make a new sketch just for the buttons...
45  Forum 2005-2010 (read only) / Syntax & Programs / desired result not being achieved with button pad on: March 29, 2008, 11:19:00 am
hi!

i'm tryig to make my button pad work, anmd i'm working on the actual buttons now, so from my code, you will notice i turn pins 0-3 on and off, one by one so i can scan which row of and column button is being pressed, but unfortunitly when i debug by printing in the value, it only half works, and half the butto pad is not even acknowledged...

so here is my code, if u need help understanding what i did and why, please ask, becuase this is the finale step to get this code working smiley

::

Code:
#define DATAOUT 11//MOSI
#define DATAIN 12//MISO - not used, but part of builtin SPI
#define SPICLOCK  13//sck
#define SLAVESELECT 10
byte potpin = 0;
byte r1=0;  //sets the correct pins to the right color, do not change!
byte g2=1;
byte g1=2;
byte b2=3;
byte b1=4;
byte r2=5;
byte delay1 = 100; // my delay value
byte val1 = 0;  // the value i hope to fade
byte direction = 0;
char spi_transfer(volatile char data)
{
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
  {
  };
  return SPDR;                    // return the received byte
}

void setup()
{
  byte i;
  byte clr;
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(SLAVESELECT,OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(15, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(16, INPUT);
  pinMode(17, INPUT);
  pinMode(18, INPUT);
  pinMode(19, INPUT);
  digitalWrite(SLAVESELECT,HIGH); //disable device
  // SPCR = 01010000
  //interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
  //sample on leading edge of clk,system clock/4 (fastest)
  SPCR = (1<<SPE)|(1<<MSTR);
  clr=SPSR;
  clr=SPDR;
  delay(10);
  for (i=0;i<6;i++)
  {
    write_pot(i,255);
  }
}

byte write_pot(int address, int value)
{
  digitalWrite(SLAVESELECT,LOW);
  //2 byte opcode
  spi_transfer(address);
  spi_transfer(value);
  digitalWrite(SLAVESELECT,HIGH); //release chip, signal end transfer

Serial.begin(9600);}
void loop()
{
 Serial.println(digitalRead(18));

  digitalWrite(15, LOW);
  digitalWrite(14, HIGH);
delay(delay1);
  digitalWrite(7, LOW);                    //button 1, 1  and 1, 2:
//if( digitalRead(1) = HIGH && digitalRead(16) == HIGH )
//{ write_pot(r1, 0);}
//else
//{write_pot(r1, 255);}
 delay(delay1);
 digitalWrite(0, HIGH);
 digitalWrite(7, HIGH);
 digitalWrite(6, LOW);                // button 2, 1 and 2, 2:
//write_pot(r1, 255);
 delay(delay1);
 digitalWrite(0, LOW);
 digitalWrite(1, HIGH);
 digitalWrite(5, LOW);
 digitalWrite(6, HIGH);                // button 3, 1 and 3, 2:

 delay(delay1);
 digitalWrite(1, LOW);
 digitalWrite(2, HIGH);
 digitalWrite(4, LOW);
 digitalWrite(5, HIGH);                  //button 4, 1 and 4, 2:

 delay(delay1);
 digitalWrite(2, LOW);
 digitalWrite(3, HIGH);
 digitalWrite(4, HIGH);

digitalWrite(15, HIGH);
digitalWrite(14, LOW);
    
                     // second relay starts here
           delay(delay1);              
 digitalWrite(3, LOW);                
 digitalWrite(7, LOW);            // button 1, 3 and 1, 4:


  delay(delay1);
 digitalWrite(7, HIGH);
 digitalWrite(6, LOW);               //button 2, 3 and 2, 4:

 delay(delay1);
 digitalWrite(5, LOW);
 digitalWrite(6, HIGH);             //button 3, 3 and 3, 4:

 delay(delay1);
 digitalWrite(4, LOW);
 digitalWrite(5, HIGH);              // button 4, 3 and 4, 4:

 delay(delay1);
 digitalWrite(4, HIGH);




}
Pages: 1 2 [3] 4 5 ... 35