Pages: 1 [2] 3   Go Down
Author Topic: NOOB needs help (7 segment countdown)  (Read 6091 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26545
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't have the transistors wired in place yet, do you? I'll look at your video again to confirm.

If that's the case, all the Highs & Lows for pins 2-3-4 and 5-6-7-8-9-10-11 need to be swapped :
2 High turns on CommonAnode2, while 5-6-7-8-9-10-11 low would bring the Cathodes Low & make an 8 appear.

If you do have the transisters, than post the schematic, is hard to tell what you have from the brief camera glimpse.

Minor thing; you don't turn the relay off when done.



« Last Edit: July 07, 2011, 08:59:48 am by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



http://snuletek.com/ting/adsgf.png
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

dont know if the arrows are correct, however the hardware works. tested it by manualy setting pnp low and npn high
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25874
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
switch(var)
  {
    case 0:
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    break;
Have you got an aversion to arrays and for loops, or do you just enjoy typing?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26545
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Awol,
Writing out the digits may look a little longhand, but it should work okay.

Any ideas as to why the digits don't appear to be changing?
Does the cycle time just need to be slowed down some more?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just let the ardweeny stand out of the socket over night.

now it works! smiley-grin

just added the turn of relay thing smiley-razz

thanks ALOT guys smiley-grin

the only difference is that the arduino and the segments now run off the same voltage supply (USB) but it works!!! YAY smiley-grin
Thaaanks! smiley-grin
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26545
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeaaa,

but:
"the only difference is that the arduino and the segments now run off the same voltage supply (USB)"
What were they running from before? And did the other source have its ground connected to the Arduino ground?

Since its running, how about another video?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

here is a video of the code working smiley-grin

thanks alot for the help smiley-grin

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh yeah, and pretty sure i fixed the ghost effect, also a code using variable in the function is on its way (so that other people can use it smiley )
« Last Edit: July 08, 2011, 04:27:51 am by dumle29 » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26545
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, glad to see it working!

Not sure what you're referring to here
"also a code using variable in the function is on its was "
but I guess you are planning ahead for something. smiley-cool
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 57
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just did it like this:

Code:
void setup()                    //setting up the pins for the segments button and relay
{
  pinMode(Disp1, OUTPUT);
  pinMode(Disp2, OUTPUT);
  pinMode(Disp3, OUTPUT);
  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);
  pinMode(button, INPUT);
  pinMode(relay, OUTPUT);
}

and

Code:
    case 0:
    digitalWrite(segG, LOW);
    digitalWrite(segA, HIGH);
    digitalWrite(segB, HIGH);
    digitalWrite(segC, HIGH);
    digitalWrite(segD, HIGH);
    digitalWrite(segE, HIGH);
    digitalWrite(segF, HIGH);
    break;
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26545
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice! Much more readable/followable that way smiley
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry to interupt guys, I see in your code you are using a "Look up Table" technique to display the digit ( 0-9 ) , If that is the case, why not use one 7447 ( open collector ) or 7448   to display 0 to 9, connect the segments together ( a with all the a's , b with all the b's ... ) use one PNP ( com anode ) or NPN ( com cathode ) for each digit.  Here a code I made to display 4 LEDs counting 0 to 15 in binary  ( 4 bit ) Maybe some modifications of the code could work. Heh , This is just an idea.

Code:
/*
Version 1.2
Size: 1172 Bytes

This program will count 0 to 15 and display the result in binary.

TESTED and WORKING

The hardware is connected to a transistor to use as a switch.

Need : 4 Transistor : Common NPN ex: 2N3904
       4 1 K resistor : between the digital pin and the base of the transistor.
       4 LED : Any color
       4 330 ohms resistor : current limiting for the LED.
       
And try to power the LEDs circuit seperated. And don't forget to connect the gnd of the
circuit with the Arduino GND.

Created by Serge Desjardins  --->  Techone
           Toronto, ON   CANADA

Idea from "Bit Math Tutorial by CosineKitty" in Arduino Playground.
           
*/

const int led[4] = {9,10,11,12};

/* Set Output LEDs  --->  A B C D   MSD --- LSD
          Digital pin    12 11 10 9

   Common variables
*/

int pin;
int counting;


void setup()

/*
  Set the pin 12, 11 , 10 , 9  to OUTPUT
*/
{
   for (pin =0; pin < 4; pin++ )
   {
     pinMode (led[pin], OUTPUT);
   }   
}

void loop()

/* 
  Counting routine from 0 to 15 and wait for 1 second
*/
{
 for ( counting = 0; counting < 16; counting++)
 {
    LEDview();
    delay (1000); // The One second delay
 }
}

void LEDview()

/*
  The LED display subroutine. The trick is to brake down the 4 bit data
  ( 0 to 15 ---> 0000 to 1111, so I need HIGH or LOW ( 1 or 0 ) Humm ... boolean
 
  Version 1.2
 
  I use the ---> bitRead(data, bit_to_read);
 
 To isolate the proper bit.

My idea came from "Bit Math Tutorial by CosineKitty" in the Arduino playground

From there, you can use a 7447 to count the data ( change 16 to 10 in the counter line ) or
other use if need parallel data, the only limitation is the digital lines do not come out at the same
time, but in this way, it is almost at the same time. Bear in mind the small delay after each digitalWrite
instruction.

*/
{
 
  boolean A=bitRead(counting,3);
  boolean B=bitRead(counting,2);
  boolean C=bitRead(counting,1);
  boolean D=bitRead(counting,0);
 
  /*
     This small change I did simply store the bit to display in A, B, C and D in boolean
     value ( 1 or 0 ) and use bitRead (data, bit_location). And I notice it reduce 10 bytes
     of the original program.
  */
 
  digitalWrite (led[3], A);
  digitalWrite (led[2], B);
  digitalWrite (led[1], C);
  digitalWrite (led[0], D);
}
 
     
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26545
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That would have worked as well, vs 7 discrete transisters.
Still need to "look  up" the 4 bits to send out to the decoder, vs the 7 bits to discretely control the transistors.
Could have used a shift register as well, loaded via shift-out, or via SPI.
Many ways to skin a cat ...
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley-confuse The use of shift-out instruction would be an idea, depending of the application. A "Look-Up Table" Technique would be ideal if you want to display 0 to F ( a 7447 or 48 only display BCD digit only ). I was thinkink and I was looking the book title "The 8085A Microprocessor Software, programing, and architecture" ( I know it's old book !!! ) . My idea is take the integer and convert to BCD example: 369   ---> 3 - hundren's, 6 - ten's, 9 - unit's. Here a convert to BCD code.

Let say you want to display a multi digit into the multiplex program ( I will do the program later  ) and count 0 to  999 and display it. First convert the number into BCD , using loop line display one digit at a time, Example : 369  display 3 - 0011 into 7447 and turn on the proper display, wait, next display - 0110 into 7447 and turn on the next display and finally 9 - 1001 into 7447 and turn on the last display.  Use the code routine of my last posting to send to the 7447 chip.  Anyway, I will make the program and I will tested.  That will be my way.    smiley 


Code:

/*
 Convert the number 369 to BCD.
 By Serge J Desjardins, Toronto, Ontario, Canada
 */
int test;
int dataone;
int datatwo;
int datathree;

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

void loop()

// 369 to be converted
{
  dataone=369/100; // to isolate 3 - no float the rest will cutoff
  Serial.println(dataone);
  delay (2000);
  test=369 % 100;
  datatwo=test/10; // to isolate 6
  Serial.println(datatwo);
  delay (2000);
  datathree=test % 10; // to isolate 9
  Serial.println(datathree);
  delay(2000);
  }
 

Logged

Pages: 1 [2] 3   Go Up
Jump to: