Wiring AD5220 fo a 7-segment display
Matt Bryant
Posts: 5
I have a 7-segment display wired on a BASIC Stamp Homework Board.· I am attempting to run a numerical loop on the display with a button to stop the loop and when the loop is stopped use a potentiometer to cycle through the numbers.· How would I wire the microcontroller to the display?· I have looked at pin layouts and got confused.· Thanks in advance for the responses.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I am in the same class at Matt and we are running into some problems, as he stated before.·Let me start from the beginning to help those fully understand what we are trying to accomplish.
This may seem very simple to some, but this is our first time·dealing with·one of these... so please be gentle
-We had the idea to·make·the 7 segment display count in hexadecimal numbers: 0-F
-We wired up the display and wrote the code for it to work
-Added in a loop to make it·a continuous count.
We got that working just fine! The problem we are facing now is that we are trying to add in a few things to make it have that "WOW" factor to ensure us the A+.
Trying to add in a button so that when we press it, it starts the counting, then press it again it stops... what we WANT to do is make the button stop it, and then incorporate a potentiometer to filter through the numbers. Before we get to the potentiometer part we need to make the button work. We have it so when it is pressed it starts, but it wont stop once its pressed again. I know we need some form of IF-AND-ELSE statement of some kind, but im having a hard time finding one... and the ones I have come accross are not what we need.
So all in all, im at a loss. No clue where to go next and the semester is coming to a close!
If anyone has any idea where to go next, please let me know [noparse]:)[/noparse]
Thanks,
Alan
' {$STAMP BS2}
' {$PBASIC 2.5}
' Pattens of 7-Segment Display to create numbers 0-F
DO
DEBUG ? IN3
IF (IN3 = 1) THEN
OUTH = %00000000
DIRH = %11111111
' BAFG.CDE
OUTH = %11100111
PAUSE 1000
OUTH = %10000100
PAUSE 1000
OUTH = %11010011
PAUSE 1000
OUTH = %11010110
PAUSE 1000
OUTH = %10110100
PAUSE 1000
OUTH = %01110110
PAUSE 1000
OUTH = %01110111
PAUSE 1000
OUTH = %11000100
PAUSE 1000
OUTH = %11110111
PAUSE 1000
OUTH = %11110110
PAUSE 1000
OUTH = %11110101
PAUSE 1000
OUTH = %00110111
PAUSE 1000
OUTH = %01100011
PAUSE 1000
OUTH = %10010111
PAUSE 1000
OUTH = %01110011
PAUSE 1000
OUTH = %01110001
PAUSE 1000
DIRH = %00000000
DIRH = %00000000
ENDIF
LOOP
END
Just a real quick look. When are you reading the input from your switch to stop the program.
Here is what I see.
Display number, wait 1 second. and repeat.
You either want to read the switch before or after the pause 1000.
Better yet put it into a for next loop that can read the input pins while the pause between number takes effect.
Make this a subroutine and run between each number.
display number 1
gosub check
display number 2· ......
check:
For I = 1 to 100
· read input pin
··· if triggered
····· gosub triggered routine.
··· else
· pause 10
next
return
You could also increase the for next to 1000 and the pause to 1. This would give you slightly more than a 1 sec pause but increase the ability to see a triggered pin.
Chuck
Post Edited (Chuck Thomas) : 10/18/2009 9:31:12 PM GMT
When I enter in this code, I get the error 'Expected a variable.' If you could please explain this line of code, it would be greatly appreciated.
Page 55 of the What's a Microcontroller will explain a for..next loop or use the help menu for a better explaination.
For I = 1 to 100················· "I" is a variable. It must be declared normally at the top of the program. That would solve your error.
·······································In this case "I" can be a byte. A Byte can be a number up to 255.
······································· I VAR Byte
······································· If you use a pause of 1 and an if..then of 1000 then "I" needs to be a Word
· read input pin··················· 'This not the actual command this just says what needs to be done.
······································· Look up INA in the help menu or page 78. It will also explain variables.
··· if triggered····················· Look up if..then...else page 81 or in the help menu.
····· gosub triggered routine.·· look up gosub page 206 or in the help menu
··· else
· pause 10
next
You should now have enough information to complete your project. If you have questions after reading the book and working out the book examples come back and post follow up questions.
Chuck