Go Down

Topic: Help in Kitchen Automation Project Timer/interval using visual basic 2010 button (Read 263 times) previous topic - next topic


We have a project where we are using Arduino and Viusal Basic 2010. Now We are trying to put a timer in our program. We use a string to control arduino in visual basic, to toggle the led on and off. We already done that. But we are having a hard time programming arduino to turn off after a button in visual basic is clicked. I have tried using delay, which has its disadvantage because I cannot override anymore functions unless the delay is finished. I have also tried millis but it repeatedly turns on and off after the interval used. How can I turn off led for a specific interval using a button in visual basic 2010? This is the first time I've used Arduino so I'm having a really hard time. Any help will be appreciated.


look at the example of blink without delay.

The Arduino has a system clock.
you pick a point to say 'start counting'
then look to see if it has timed out yet.

your start must be set in such a way that it only sets once on the switch and does not set on every run through the code.


May I know the code for this time clock so I could further research on how to use it?
This is what I'm having now. I've been altering codes here and there but to no avail.

const int led =  2; // the number of the green LED pin
const int led2 = 4;    // the number of the green LED pin

// Variables will change
int greenLedState = LOW; //ledState for green LED
int redLedState = LOW;   //ledState for red LED
long previousMillisRed = 0;    //last time Red LED was updated
long previousMillisGreen = 0;  //last time Green LED was updated

// must be long to prevent overflow
long greenLedInterval = 2000; //interval to blink greed LED (milliseconds)
long redLedInterval = 3000;    //interval to blink red LED (milliseconds)
unsigned long currentMillis = 0;

void setup() {
  // set the pins to output mode
  pinMode(led, OUTPUT);
  pinMode(led2, OUTPUT);
  digitalWrite(led2, redLedState);
  digitalWrite(led, greenLedState);
  currentMillis = millis();

void loop()
  // capture the current time
  currentMillis = millis();

void manageRedLed() {  //check if it's time to change the Red LED yet

String vb;

if (vb=="ON3") {
  digitalWrite(led2, HIGH);
  if (currentMillis - previousMillisRed > redLedInterval) {
    //store the time of this change
    previousMillisRed = currentMillis;
   if (redLedState == HIGH) {
     redLedState == LOW;
    digitalWrite(led2, redLedState);

void manageGreenLed() {
  //check if it's time to change the green LED yet
  if(currentMillis - previousMillisGreen > greenLedInterval) {
    //store the time of this change
    previousMillisGreen = currentMillis;
    if (greenLedState == HIGH){
      greenLedState == LOW;
    digitalWrite(led, greenLedState);

*@dave-in-nj Thanks for your advice and help mate. I've found what I need in my program. I read it on http://playground.arduino.cc/Code/AvoidDelay . :D

Go Up