Go Down

Topic: NOOB needs help (7 segment countdown) (Read 7265 times) previous topic - next topic

CrossRoads

#15
Jul 07, 2011, 03:55 pm Last Edit: Jul 07, 2011, 03:59 pm by CrossRoads Reason: 1
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.



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.

dumle29



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

dumle29

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

AWOL

Code: [Select]
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?
"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.

CrossRoads

@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?
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.

dumle29

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

now it works! :D

just added the turn of relay thing :P

thanks ALOT guys :D

the only difference is that the arduino and the segments now run off the same voltage supply (USB) but it works!!! YAY :D
Thaaanks! :D

CrossRoads

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?
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.

dumle29

here is a video of the code working :D

thanks alot for the help :D

http://www.youtube.com/watch?v=77dwFKgJSTo

dumle29

#23
Jul 08, 2011, 03:32 am Last Edit: Jul 08, 2011, 11:27 am by dumle29 Reason: 1
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 :) )

CrossRoads

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. 8)
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.

dumle29

just did it like this:

Code: [Select]
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: [Select]
    case 0:
    digitalWrite(segG, LOW);
    digitalWrite(segA, HIGH);
    digitalWrite(segB, HIGH);
    digitalWrite(segC, HIGH);
    digitalWrite(segD, HIGH);
    digitalWrite(segE, HIGH);
    digitalWrite(segF, HIGH);
    break;

CrossRoads

Nice! Much more readable/followable that way :)
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.

Techone

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: [Select]

/*
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);
}
   

CrossRoads

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 ...
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.

Techone

:~ 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.    :) 


Code: [Select]

/*
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);
  }
 



Go Up