Cry for help,
BigW
Posts: 4
Hi all, I joined the Yahoo usergroup some time ago·but it seems to be pretty dead, then I stumbled across you guys while looking for some inspiration.
This is a long shot but I am having some troubles writing a couple of "Very simple" codes for my uni class, I work with nuts and bolts all day long but this is part of the curriculum so it must be done,
Would somebody be willing to give me a little hand with these programs over email and I would happily sort them out with a few beer tokens if so required, One is simply temperature measurement and alarm and the other is a pushbutton with lights, and a servo motor to open a door.
It would be appreciated
Re
BW,
[url=mailto:bigw2069@ hotmail(dot)com]bigw2069 @ hotmail(dot)com[/url]
·
This is a long shot but I am having some troubles writing a couple of "Very simple" codes for my uni class, I work with nuts and bolts all day long but this is part of the curriculum so it must be done,
Would somebody be willing to give me a little hand with these programs over email and I would happily sort them out with a few beer tokens if so required, One is simply temperature measurement and alarm and the other is a pushbutton with lights, and a servo motor to open a door.
It would be appreciated
Re
BW,
[url=mailto:bigw2069@ hotmail(dot)com]bigw2069 @ hotmail(dot)com[/url]
·
Comments
Skim those to find the parts you need. Another resource is the "nuts&Volts" articles, also on the Parallax website. These are very concise examples, with code, of implementing just what you're trying to do.
Cheers
BW
How does this look to you knowlegable chaps out there?
'
[noparse][[/noparse] Title ]
' Temperaure Measurement using ADC0831, LM358 & LM35
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Declarations ]
adcBits VAR Byte
t VAR Byte
r VAR Byte
t2 VAR Byte
t3 VAR Byte
'
[noparse][[/noparse] Initialization ]
CS PIN 0
CLK PIN 1
DataOutput PIN 2
DEBUG CLS 'Start display.
'
[noparse][[/noparse] Main Routine ]
DO
GOSUB ADC_Data
GOSUB Calc_Temp
GOSUB Display
LOOP
'
[noparse][[/noparse] Subroutines ]
ADC_Data:
HIGH CS
LOW CS
LOW CLK
PULSOUT CLK, 210
SHIFTIN DataOutput,CLK,MSBPOST,[noparse][[/noparse]adcBits\8]
RETURN
Display:
DEBUG HOME
DEBUG "8-bit binary value: ", BIN8 adcBits
DEBUG CR, CR, "Decimal value: ", DEC3 adcBits
DEBUG CR, CR, "Temperature Reading: "
DEBUG DEC2 t, ".", DEC2 t2, " Degrees C"
RETURN
Calc_Temp:
t = 50 * adcBits / 255
r = 50 * adcBits // 255
t2 = 100 * r / 255
t3 = 100 * r // 255
t3 = 10 * t3 / 255
IF (t3 >= 5) THEN t2 = t2 + 1
IF (t2 >= 100) THEN
t = t + 1
t2 = 0
ENDIF
RETURN
_____________________________________________________________________________________
I dont have the hardware here at the moment but the syntax checks out ok.
I have confused myself at this point though, I am looking to add an audible alarm and red LED if the temp drops below 10 Degrees or above 20 degrees and a green LED if it is between 10 and 20.
any chance of a kick up the Smile in the right direction please?
Re
BW