Go Down

Topic: USB device drawing too much power (beginner ques.) (Read 3 times) previous topic - next topic

Jonathan Oxer

OK, I'll probably get this wrong as well but I'll give it another go   ;-)

Code: [Select]
void loop() {
digitalWrite(LED, !digitalRead(BUTTON));
}


Better?

Hmmm, here we are talking among ourselves and don't even know if the original poster has had any success.

@PeteAJ: are we helping, or just making you more confused?

Graynomad

Oops, looks like Jon and I both go to the back of the C 101 class   :-[
Rob Gray aka the GRAYnomad www.robgray.com

PeteAJ

Jon, Mike, Graynomad.. thanks for the input. I've tried your code versions and the code itself and the suggestions/mods make sense..

I'm new to this. Working on the second example in the Massimo's 'Getting Started with Arduino' book. Controlling an LED with a pushbutton.

I went back to my original setup with the second yellow and red wires flipped in relation to the resistor 'cause that got rid of my USB power warning error as per Jeremy's suggestion.

This is what I have:  http://datavisual.tumblr.com/#1204687027

Also went back to the original code in the book:

#define LED 13
#define BUTTON 7

int val = 0;

void setup() {
   pinMode(LED, OUTPUT);
 pinMode(BUTTON, INPUT);
}

void loop() {
 val = digitalRead(BUTTON);
 
 if (val == HIGH) {
digitalWrite(LED, HIGH);
 } else {
   digitalWrite(LED, LOW);
 }
}


Replugged the USB
changed by LED ..just in case
Compile, save, upload in Arduino, and my LED still doesn't turn on.

The 2nd orange light on the Arduino board (marked L) responds to the button press (which must be a good sign).


This is only my second thing but not giving up until I figure this out.

Does it look like I have the right 10K ohm? There are 1K and 10K ones in the MakerShed starter kit and I wasn't completely convinced I'm telling them apart.

 


Jeremy1998

If you are trying to do a:
*press*
led on
*press*
led off
(repeat)
Then I have some code that is tested and working. Just let me know and I'll post it...

Eight

#19
Sep 28, 2010, 09:03 pm Last Edit: Sep 28, 2010, 09:06 pm by Eight Reason: 1
LED connected backwards? Or blown?

If the on-board LED (L) is responding correctly to your button then the code is almost certainly fine.

Edit: and yeah, that looks like a 10k resistor to me. To be honest, I cheat most of the time and use a free Resisitor Color Code app on my phone. ;)

Go Up