Loading...
  Show Posts
Pages: 1 ... 3 4 [5] 6 7 8
61  Using Arduino / Programming Questions / Re: logic help on: August 19, 2011, 01:18:28 pm
hmmm...now it is very erratic again. when i press the button the if (temp==1) condintional just keeps looping until i press the button again...and then it stops. any other ideas?
thanks!
62  Using Arduino / Programming Questions / Re: logic help on: August 18, 2011, 05:01:31 pm
thanks so much!this looks great! maybe i'm missing something, though...I'm not getting anything in my Serial.println now...
here is my code:
thanks again for the help!

Code:
#include <phi_buttons.h>
#define btn_a 7

phi_buttons btn_1(btn_a, LOW);

void setup(){
  Serial.begin(9600);
}

void loop(){

  int temp = wait_for_press(20);

  if (temp==buttons_released){
    Serial.println("Turn on");
    delay(200);
    Serial.println("Play");
    delay(2000);
    Serial.println("Turn off");
    delay(200);
    Serial.println("Wait for next press");
    delay(200);
  }

}

int wait_for_press(int ref_time) // Returns key pressed or 0 if time expires before any key was pressed.
{
  //Wait on button push.
  long temp0;
  byte temp1;
  temp0=millis();
  do
  {
    temp1=btn_1.sense();

    if((temp1==buttons_released)||(temp1==buttons_held))
    {
      return(1);
    }
  }   
  while ((millis()-temp0<ref_time));

  return (0);
}
63  Using Arduino / Programming Questions / Re: logic help on: August 18, 2011, 12:25:19 pm
thanks so much for your help! that library works better than what i had before...however a lot of times it seems to not sense() when i'm pressing the button...it seems fairly erratic...sometimes it notices I press it and sometimes it doesn't...it seems that I have to press the button twice...it's one of those buttons that's either HIGH or LOW...not the one that you press and it's only HIGH when you're pressing it...could this be why? this is my code:

Code:
#include <phi_buttons.h>
#define btn_a 7

phi_buttons btn_1(btn_a, LOW);

void setup(){

Serial.begin(9600);

}

void loop(){

int temp=btn_1.sense();

if (temp==buttons_released){
  Serial.println("Turn on");
    delay(200);
    Serial.println("Play");
    delay(2000);
    Serial.println("Turn off");
    delay(200);
    Serial.println("Wait for next press");
    delay(200);
}

}
64  Using Arduino / Programming Questions / Re: logic help on: August 18, 2011, 10:40:39 am
thanks for your help...I don't understand how having digitalRead would help solve my logic problem above?
65  Using Arduino / Programming Questions / Re: logic help on: August 18, 2011, 10:02:14 am
hi,
thanks so much for your help. it doesn't matter if the pins on the button are digital or analog, right? i mean...whether or not i get a HIGH/LOW or 0/1023 reading doesn't matter...I can still use a logic algorithm to do what i want to do, right? anyone know what i'm doing wrong with my logic? thanks!
66  Using Arduino / Programming Questions / Re: logic help on: August 18, 2011, 09:14:08 am
Thanks so much for your help. That page helped explain a lot...so now I have the button wired up correctly. I'm using the analog inputs because the digital ones will all be used when I have everything wired up.
So my code is shorter now...still having the same problem as explained above. Here is what I have now:

Code:
//button is either 0 or 1023
//if the button state changes between those numbers
//turn the photo frame on, run the vid,
//while running vid make sure other button presses don't prevent it from shutting off when done
//turn it off and do nothing while waiting for another change
int buttonState;
int oldButtonState;
boolean prevent;

void setup() {
  Serial.begin(9600);
}

void loop() {
buttonState = analogRead(0); //read it and see it the button is below 20 or above

//check to see if it changed
//if there's no change, don't do anything
//if it changed, turn on vid, turn off and wait

if((oldButtonState != buttonState)&&(prevent==false)) {
  Serial.println("Turn on lcd");
  delay(200);
  Serial.println("Play video");
  prevent = true;
  delay(2000);
  Serial.println("Turn off lcd");
  delay(200);
  Serial.println("Wait for another change");
  delay(200);
 
}
if (oldButtonState == buttonState){
  prevent = false;
}

oldButtonState = buttonState;

}
67  Using Arduino / Programming Questions / logic help on: August 18, 2011, 08:14:06 am
hello,
i am having a very hard time wrapping my brain around how to program this logic...

A user would press one button (I have some SPST buttons from radio shack) that would send a signal to an arduino to trigger some relays that would press buttons on a digital photo frame that would start a video, play the video, and turn off the frame when it's done, waiting for another state change to start the video back up again.
The buttons I have are either HIGH or LOW. I need to use them in the analog inputs because i'm using all the digital ones. When I have the button in analog I get a reading of 0 when it's LOW and something 20-200 when it's HIGH.
So every time I press the button, I want something to happen, and then stop and wait. Instead, when I press the button once, I get a loop, where Serial.println keeps repeating the test text I have...when I press the button again, nothing happens...
I set a boolean switch but the if conditional keeps looping. When the button state changes, it stops, but when it changes again it starts looping and doesn't stop.
I also am stumped as to how to make it so that if someone presses the button during the video play that the video won't start to play again right after...
Here is the test program I have so far:

Code:
//button is either greater than 20 or less than 20
//the button state changes between those numbers
//turn the photo frame on, run the vid,
//while running vid make sure other button presses aren't registered
//turn it off and do nothing while waiting for another change
int buttonState;
int buttonValue;
int oldButtonState;
boolean prevent;

void setup() {
  Serial.begin(9600);

}

void loop() {
buttonValue = analogRead(0); //read it and see it the button is below 20 or above

//normalize the readings because it gives random numbers (but they're all above 20 if it's HIGH)
if (buttonValue > 20) {
  buttonState = 30; //HIGH
}
if (buttonValue < 20) {
  buttonState = 0;  //LOW
}

//check to see if it changed
//if there's no change, don't do anything
//if it changed, turn on vid, turn off and wait
//this isn't working...it keeps looping. I don't understand why if the "prevent" boolean is set to true in the conditional.
if((oldButtonState != buttonState)&&(prevent==false)) {
  Serial.println("Turn on lcd");
  delay(200);
  Serial.println("Play video");
  prevent = true;
  delay(2000);
  Serial.println("Turn off lcd");
  delay(200);
  Serial.println("Wait for another change");
  delay(200);
  
}
if (oldButtonState == buttonState){
  prevent = false;
}

oldButtonState = buttonState;

}
68  Using Arduino / Microcontrollers / Re: problem uploading to atmega on breadboard on: June 25, 2011, 03:04:14 pm
thanks so much for your help.
I don't understand the electronics of why it would matter if the crystal is connected via jumpers or directly. When you say directly do you mean literally soldered onto a pin of the chip? why does it matter if it's connected via a jumper or just one pin away on the breadboard? There's still a connection....

what do you mean by bypassing power connections?

i guess I'm confused with what you mean by "right at the chip." why is none of this mentioned in the tutorial?

I'm certainly no electronics engineer....sorry if these are basic questions...any help is much appreciated..
69  Using Arduino / Microcontrollers / problem uploading to atmega on breadboard on: June 25, 2011, 02:15:03 pm
hello,
so i followed this tutorial EXACTLY: http://arduino.cc/en/Tutorial/ArduinoToBreadboard
at first I had the wrong crystals but then Lefty in the forums here helped me out and I got the right ones...I have 6 atmega328p-pu chips...I put the arduino bootloader on all of them no problem. Then I started putting some blink sketches on the atmegas while they were in the breadboard (no chip on arduino board)following the second part of the tutorial...that worked fine too for awhile. I got to the 4th chip, and I got the error message that you get when the board can't find/recognize the chip:
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51
5th chip did that too, 6th chip the sketch uploaded.
So I thought I had some bad chips.
But then I was playing around a little more, uploading different sketches to different chips and slowly I was getting that error message more and more and now I get it on all the chips. Even on the ones that previously took the blink sketch just fine....(I did not change any wiring...everything was exactly the same as it had been before)
BUT
when I plug the atmegas directly into the arduino board I can upload sketches to them fine.
So this isn't a huge problem as I can do what I need to do...I'm just popping out and placing the chips more than I'd like to...it's just a weird problem. I see that some people are having similar issues here...
Is this a common problem?
I'm on windows 7 64x using arduino 0021 on a duemilanove
thanks for any input!
70  Using Arduino / General Electronics / Re: 16Mhz crystal problem on: June 22, 2011, 09:08:22 am
ok so i am able to upload the arduinoISP sketch in the examples...but now when i upload arduino as ISP in tools/burn bootloader i get a weird error: (and i selected the new, proper 8mhz board)

avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.
71  Using Arduino / General Electronics / Re: 16Mhz crystal problem on: June 21, 2011, 06:03:10 pm
the instructions i specified at the top of the post (http://arduino.cc/en/Tutorial/ArduinoToBreadboard)...i'm going into tools ---> burn bootloader ---> arduino as isp
also i tried the arduino isp sketch in the examples and that got the same error...but i can upload the blink sketch just fine...
72  Using Arduino / General Electronics / Re: 16Mhz crystal problem on: June 21, 2011, 05:17:36 pm
yeah i can upload normal sketches fine...the tutorial says that you can use your pc (win7 x64) to do this...
has anyone actually done this? any advice?
73  Using Arduino / General Electronics / Re: 16Mhz crystal problem on: June 20, 2011, 09:40:41 pm
i'm just using a duemilanova with the original atmega in it to try, via usb and the arduino gui,  to program an atmega328p-pu on a breadboard...i feel like there might be some step i'm missing that's not on the tutorial page...? i followed everything on that tutorial....any other ideas? Thanks for any help!
74  Using Arduino / General Electronics / Re: 16Mhz crystal problem on: June 20, 2011, 06:31:59 pm
thanks so much for the help...i did do these steps (still to no avail):

1.Download this hardware configuration archive: breadboard.zip
2.Create a "hardware" sub-folder in your Arduino sketchbook folder (whose location you can find in the Arduino preferences dialog). If you've previously installed support for additional hardware configuration, you may already have a "hardware" folder in your sketchbook.
3.Move the "breadboard" folder from the zip archive to the "hardware" sub-folder of your Arduino sketchbook.
Restart the Arduino software.
4.You should see "ATmega328 on a breadboard (8 MHz internal clock)" in the Tools > Board menu.

this is what's on the .txt file:

##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=stk500
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xD9
atmega328bb.bootloader.extended_fuses=0x07
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
75  Using Arduino / General Electronics / Re: 16Mhz crystal problem on: June 20, 2011, 06:15:25 pm
i just tried the example to use the 8Mhz internal clock...still getting the same error...i have the right board selected, too...the one with the breadboard...wired everything up just like the xample at the bottom http://arduino.cc/en/Tutorial/ArduinoToBreadboard

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

any ideas?
Pages: 1 ... 3 4 [5] 6 7 8