Would also like to create a serial display output for temp sensor for testing purposes. I would like to use the 'millis' function over 'delay', create a full function for the temp, fan and alarm calls so in the loop structure I can just call the function within the switch/case statement. Am I on the right path with the switch/case statement? Seems like it fits the bill and makes the whole structure pretty clean. If (battery_temperature >= battery_Alarm_Point)ĪlarmOFF = 1 // flag to prevent repeatingīattery_temperature = digital.read(temp_sensor)Īnyways, I got to push off for work, this is just a rough outline but I think it represents the structure I would like to see. Int temp_Sensor(input) //th02 temp sensorīattery_temperature = digital.read(temp_sensor) // read sensor always Void setup() // I want to create these objects as global functions This is just pseudo code to get a sketch laid out. I sure hope another newbie whom stumples upon this little saga gets some benefit.īeen doing some research and I think I got a basic code structure laid out in my mind so I want to throw it out here and get some feedback. I am going to go for a walk on the beach and have fish tacos to celebrate my little accomplishment here. Ok so there it is, I wrote my first successful Arduino code and have figured out the fundamental logic of how this all works. PinMode(2, OUTPUT) //ground control for buzzerĭigitalWrite(2, LOW) // turn the buzzer on by making the voltage LOWĭigitalWrite(2, HIGH) // turn the buzzer off initialize digital pin 2 as an output. So this whole time it only did what I wanted it to do, beep 5 times, but that is all I ever told it to do. You tell it to do something and that is what it does, period, forever!!!! Then it dawns on me like the rising sun.There are only 2 main functions in Arduino.īecause its a damn microcontroller you doofus! Hmmm? So I change it back to 'void loop()' and add the 5 second delay in place of the return 0 statement and upload it, it beeps 5 times, waits 5 seconds, beeps 5 seconds. It compiled without error and uploaded without error, and I was met with deafening silence. Nope it just beeps, and beeps, and beeps.Then I notice, its main function is 'void loop()', easy enough so I change it to 'int main()' and add my end return 0 statement. So then I have an aha moment, I need to add a return 0 statement to let the Arduino program to exit. I was in the shower and thinking 'if its in a loop and it beeps 5 times and restarts the loop and reads that t=0 and if t Ok I think I made an important discovery this morning. You "yeah, I guess it went off when no one was around to hear it, then it shut itself down" If someone presses the acknowledgement button, silenceīoss "I thought you had an alarm for that?" Wake up, have coffee, no coffee, alarm, go so sleep for 23-1/2 hoursīeep alarm 5 times, 100 mS on and 500mS off It seems you have some desire to stop the loop. No one likes to use delay but for an alarm like this, who cares if nothing else is measured or controlled ?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |