Would like to fill a bucket of water at the push of a button
okay. i'd valve upon on relay fill bucket water @ push of button. valve should close when bucket full , system should wait button push.
button, ultra sonic sensor (sensing full bucket), relay , valve within grasps , hense control.
what need figure out code makes happen.
is i've got.
i've tested button push in seperate code , it's working.
i've tested ultra sonic , relay in seperate code , they're working.
the combination still need figure out.
any suggestions? i'd system reset when bucket full , wait re-activated bucket , button push.
button, ultra sonic sensor (sensing full bucket), relay , valve within grasps , hense control.
what need figure out code makes happen.
code: [select]
#include <button.h>
#define button_pin 2 // forbindes til gnd
#define pullup true
#define invert true
#define debounce_ms 20
#define echopin 7 // echo pin //ny
#define trigpin 8 // trigger pin //ny
#define relaypin 9 // relæ pin //ny
button mybtn(button_pin, pullup, invert, debounce_ms);
boolean ledstate;
int maximumrange = 10; // afstand cm til vandspejl
int minimumrange = 0;
long duration, distance;
void setup(void)
{
serial.begin (9600);
pinmode(trigpin, output);
pinmode(echopin, input);
pinmode(relaypin, output);
pinmode(13, output);
digitalwrite(13,low);
}
void loop(void)
{
mybtn.read();
if (mybtn.waspressed()) {
digitalwrite(trigpin, low);
delaymicroseconds(2);
digitalwrite(trigpin, high);
delaymicroseconds(10);
digitalwrite(trigpin, low);
duration = pulsein(echopin, high);
distance = duration/58.2;
if (distance >= maximumrange || distance <= minimumrange){
digitalwrite(relaypin, low);
}
else {
digitalwrite(relaypin, high);
}
delay(30);
}
}
is i've got.
i've tested button push in seperate code , it's working.
i've tested ultra sonic , relay in seperate code , they're working.
the combination still need figure out.
any suggestions? i'd system reset when bucket full , wait re-activated bucket , button push.
quote
any suggestions?start state change detection example. when switch becomes pressed, instead of incrementing counter, call function, fillbucket().
initially, fillbucket() should turn led on 10 seconds, , turn off.
when works, replace led relay, , turn relay on 10 seconds, , turn off.
when works, replace code turn relay off after 10 seconds code turn relay off when ping sensor says bucket full.
incremental development far more rewarding (hey, worked!) trying write code @ once.
Arduino Forum > Using Arduino > Programming Questions > Would like to fill a bucket of water at the push of a button
arduino
Comments
Post a Comment