Show Posts
Pages: 1 ... 4 5 [6] 7 8 ... 10
76  Using Arduino / General Electronics / stereo sound on: August 29, 2011, 10:58:21 am
Hi,

I have some cheap Dell computer speakers...powered independently from the Arduino. When I plug them into the Arduino using a standard mono jack, obviously, just one of the speakers plays a tone() command.

Is there any way to get the other speaker to do anything without hacking the computer speakers? Is there anyway to get the Arduino to tell the computer speakers to play the next tone() in the other speaker? If I had a stereo jack would that work?

Sorry...this is probably a pretty dumb question...

Thanks for any help!
77  Using Arduino / General Electronics / 3 atmegas, one wall wort on: August 26, 2011, 12:32:20 pm
Hello,

Quick question...I just want to make sure before I put it together...that I would be okay to use three ATMega 328p-pu's with one 9v wall wort and one 7805 voltage regulator. Would I need three voltage regulators, one for each chip? Or is one okay?

Thanks for any input
78  Using Arduino / Microcontrollers / Re: Bootloader won't burn on 328p on: August 24, 2011, 04:01:14 pm
i'm no expert...but i was having this same problem..switched to the old 018 build...and now it's fine for some reason...
79  Using Arduino / Programming Questions / change pinMode? on: August 21, 2011, 03:20:44 pm
Hello,
I was wondering if there's a way to change the behaviour of a pin mid program. I have a button that I want to sort of shut off while a conditional is running. If in void setup() i have, say, pinMode(button1, INPUT); and then in the if conditional i have if (oldButtonReading != newButtonReading) {.....and then while that conditional is running, I don't want the arduino to be reading anything from button1. Is this possible? Could I change pinMode to OUTPUT or something just while it's in that if ()?
Another option is that I could set up a little 5V relay or something to just break the connection but it'd be way easier to do something with the code.
thanks for any help!
80  Using Arduino / Programming Questions / Re: logic help on: August 20, 2011, 07:53:02 am
bummer...well...i'm sort of visually attached to that button. this is for a visual art project. is there any way to write code to make this button behave like the other one? or is it pretty much impossible?

thanks again for all the help.
81  Using Arduino / Programming Questions / Re: logic help on: August 19, 2011, 05:34:01 pm
i'm using one of these buttons:

http://www.radioshack.com/product/index.jsp?productId=2062544

it is a click button...pushes on and off. is this the problem?

i have it set up with a 1k pull up resistor...like on this page:
http://www.thebox.myzen.co.uk/Tutorial/Inputs_files/shapeimage_9.png

could it be because i'm using a 1k and not 3k like in the diagram?

thanks so much for all the help
82  Using Arduino / Programming Questions / Re: logic help on: August 19, 2011, 03:58:31 pm
i took out the delays...now it just plays the if conditional on a loop until i press the button...when i press it, it stops, when i press it again, the loop starts again. i just want it to play a video and then stop and wait for another button press...i need the delays in there because there needs to be delays in between the arduino triggering the relays...

could this be because this library might not be for buttons that are either HIGH or LOW?

this is my other program i wrote...it works fine...it's just that while the video is playing i don't want it to register any button presses:

Code:
int buttonState;
boolean occuring;
int oldButtonState;

void setup() {
  Serial.begin(9600);
  pinMode(7, INPUT);
}

void loop() {
  buttonState = digitalRead(7);

  if (oldButtonState != buttonState) {
    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);
  }

  oldButtonState = buttonState;
}
83  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!
84  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);
}
85  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);
}

}
86  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?
87  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!
88  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;

}
89  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;

}
90  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..
Pages: 1 ... 4 5 [6] 7 8 ... 10