Mturk Jobs

Mturk Jobs
Mturk Jobs

Tank

Showing posts with label No Parts Arduino Stroboscope. Show all posts
Showing posts with label No Parts Arduino Stroboscope. Show all posts

Monday, March 19, 2018

No Parts Arduino Stroboscope - Control LED Blink rate with Serial Monitor

In this post I'm coding for Arduino program that can control blink rate of an LED.

I tried to make it very simple.

Here you can see minimum hardware used:

Arduino UNO
Arduino USB cable
White LED
Laptop with Arduino IDE


I chose Arduino UNO from the drop down menu.






Then opened Blink example.

And then I got the code that reads serial monitor to control LED and changed it to control blink rate.


/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.



 */





int led = 8;
int MyDelay = 50 ;
// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT); 
  pinMode(13, OUTPUT); 
  digitalWrite(13, LOW);  
  
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Input 1 to increase delay on and 2 to decrease delay ");
}
  void change_rate() {
  
      if (Serial.available())
  {
    int state = Serial.parseInt();
    if (state == 1)
    {

     if(MyDelay < 1000 ) 
     MyDelay = MyDelay + 10 ; 
      
     Serial.println("Command completed delay increases");
    }
    if (state == 2)
    {
      
      
     if(MyDelay > 0 )  
     MyDelay = MyDelay - 10  ;
     Serial.println("Command completed delay decreases");
    }  
  }
    
    
    
}

// the loop routine runs over and over again forever:
void loop() {
  
  change_rate();
  
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(10);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(MyDelay);               // wait for a second
  
  
  
  
  
}










Paid Online Surveys

Check our books on Amazon we created on our way to find happiness.


A Trip To Siwa Oasis: Tourist guide to an Egyptian Oasis by [ElSakhawy, Sara M.]


A Trip To Siwa Oasis




The Ultimate travel bag list by [ Elskhawy, Sara M.]














Tank