This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
2
Pushing a button based on sensor readings
Post Flair (click to view more posts with a particular flair)
Post Body
So I'm controlling a fan with a solenoid. Why? The fan manufacturer put in soft PWM fades when changing speeds. I didn't want to rip the fan apart for a better solution, so I decided to use a small solenoid to press the buttons.
The fan switch has 9 positions, starting at OFF and going up to HIGHEST.
My question is, is there a better way to code this? What I have is working, but I think I might could learn something here.
See below:
//Temperature conditions, speed 1 is off, 9 is highest
buttonpresses=0;
if (board1temp==0){ //this is for startup, while waiting for data
buttonpresses=0;
}
if (board1temp > 79){
newspeed=8;
buttonpresses = newspeed-oldspeed;
}
if (board1temp <78 && (board1temp != 0)){
newspeed=2;
if (oldspeed==newspeed){
buttonpresses=0;
}
if (oldspeed<2){
buttonpresses = 1;
}
else if (oldspeed>7){
buttonpresses = 3;
}
}
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/arduino/com...