Go Down

Topic: Newbie question on Standalone ATMega (Read 3001 times) previous topic - next topic

SloppyJoe

My teacher said to connect CD+ on the ULN's to the +12 I'll be supplying the 7-segs so that when the ATMega goes low, it'll supply them with the +12 they need to work, instead of the +5 supplied by the chip. Is this not how they work?

I tried having A0 - A5 connected to ground like digital inputs, but I was getting really screw results while breadboarding. The switches were closing unreliably, just by tapping or getting close to the actual wires without having to actually press the buttons. Once I put the resistors in, that solved all my problems.


CrossRoads

Connecting the COM on the ULN2003 to +12V will not do anything for you.
Connecting +12V to your anodes, then a resistor, then the outputs of the ULN2003 is what you need.

A0-A5 - did you try this? Simple test to see if a pin is grounded with a momentary button, internal pullup resistor holds the  pin high.
Code: [Select]

button0 = 14; // pin A0
button1 = 15; // pin A1
button2 = 16; // pin A2
button3 = 17; // pin A3
button4 = 18; // pin A4
button5 = 19; // pin A5
pin13LED = 13;  // on board LED for testing

void setup(){
pinMode (button0, INPUT);
digitalWrite (button0, HIGH); // turns on internal pullup
pinMode (button1, INPUT);
digitalWrite (button1, HIGH); // turns on internal pullup
pinMode (button2, INPUT);
digitalWrite (button2, HIGH); // turns on internal pullup
pinMode (button3, INPUT);
digitalWrite (button3, HIGH); // turns on internal pullup
pinMode (button4, INPUT);
digitalWrite (button4, HIGH); // turns on internal pullup
pinMode (button5, INPUT);
digitalWrite (button5, HIGH); // turns on internal pullup
pinMode (pin13LED, OUTPUT);
}
void loop(){
if (digitalRead (button0) == LOW){  // button0 switch pressed to connect it to ground?
digitalWrite (pin13LED, HIGH); // turn on the onboard LED for 0.1 second
delay (100);
digitalWrite(pin13LED, LOW);
}
if (digitalRead (button1) == LOW){  // button1 switch pressed to connect it to ground?
digitalWrite (pin13LED, HIGH); // turn on the onboard LED for 0.1 second
delay (100);
digitalWrite(pin13LED, LOW);
}if (digitalRead (button2) == LOW){  // button2 switch pressed to connect it to ground?
digitalWrite (pin13LED, HIGH); // turn on the onboard LED for 0.1 second
delay (100);
digitalWrite(pin13LED, LOW);
}if (digitalRead (button3) == LOW){  // button3 switch pressed to connect it to ground?
digitalWrite (pin13LED, HIGH); // turn on the onboard LED for 0.1 second
delay (100);
digitalWrite(pin13LED, LOW);
}if (digitalRead (button4) == LOW){  // button4 switch pressed to connect it to ground?
digitalWrite (pin13LED, HIGH); // turn on the onboard LED for 0.1 second
delay (100);
digitalWrite(pin13LED, LOW);
}if (digitalRead (button5) == LOW){  // button5 switch pressed to connect it to ground?
digitalWrite (pin13LED, HIGH); // turn on the onboard LED for 0.1 second
delay (100);
digitalWrite(pin13LED, LOW);
}
}

There is no reason for the A0-A5 pins to act screwy when they are defined as digital pins. No resistors are needed.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

SloppyJoe

The 7-segs are common anode, so I've got +12V running to the anode. The cathodes are then hooked up to the output side of the ULN2003's.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy