I need help with arduino intervalometer for Canon EOS 70D

Hi, I want the program to read serial data and change code based on it. And save it. I need it to change the timing. This line


I need help again.
This is the code of the intervalometer. I will make a c# program

Thank You JIM LEE!
#include <mechButton.h>    // Silver bullet 1 deals with a button.
#include <blinker.h>       // Silver bullet 2 deals with the LED/Output pin.

#define OUTPUT_PIN      3
#define BUTTON_PIN      4        // The pin nunber for the button.
#define BUTTON_PRESSED  LOW      // If its backwards make this HIGH.

#define LED_1  5
#define LED_2  6
#define LED_3  7
#define LED_4  8
#define LED_5  9

blinker     theBlinker(OUTPUT_PIN,50,5000);  // An object that toggles an output pin.
mechButton  theButton(BUTTON_PIN);           // An object that manages a button on an input pin. Debounce, all them things.
bool        buttonState;                     // Holder for the state of our button.
int         mode;                            // Holder for the state of our output.

// Standard setup.
void setup() {

   pinMode(LED_1, OUTPUT);
   pinMode(LED_2, OUTPUT);
   pinMode(LED_3, OUTPUT);
   pinMode(LED_4, OUTPUT);
   pinMode(LED_5, OUTPUT);
   theBlinker.setOnOff(false);            // This initial call will initialse the pin and set the LED off.
   mode = 0;                              // We start at LED off. (Mode 0)
   buttonState = theButton.trueFalse();   // Read and note initial button state.

// We have seen the button change states. Lets deal with it.
void buttonChange(void) {

   if (theButton.trueFalse()==BUTTON_PRESSED) {       // If the button is in the pressed state..
      switch(mode) {                                  // Looking at mode, we want to chage to..
         case 0 :
            theBlinker.setPeriod(5000);               // Setting the blinker 5 seconds.
            theBlinker.setOnOff(true);                // Fire up the blinker.
            mode = 5;                                 // We are now in mode 5.
            digitalWrite(LED_1, HIGH);
         break;                                       // And we're done.
         case 5 :                                     // We are running 5 sec wait, want 10.
            theBlinker.setPeriod(10000);              // Setting the blinker 10 seconds.
            mode = 10;                                // We are now in mode 10.
            digitalWrite(LED_1, LOW);
            digitalWrite(LED_2, HIGH);
         break;                                       // Done, bolt!
         case 10 :                                    // We are running 10 sec wait, want 20.
            theBlinker.setPeriod(20000);              // Setting the blinker 20 seconds.
            mode = 20;                                // We are now in mode 20.
            digitalWrite(LED_1, LOW);
            digitalWrite(LED_2, LOW);
            digitalWrite(LED_3, HIGH);
         break;                                       // Our work is done here.
         case 20 :                                    // We are running 20 sec wait, want 30.
            theBlinker.setPeriod(30000);              // Setting the blinker 30 seconds.
            mode = 30;                                // We are now in mode 30.
            digitalWrite(LED_1, LOW);
            digitalWrite(LED_2, LOW);
            digitalWrite(LED_3, LOW);
            digitalWrite(LED_4, HIGH);
         case 30 :                                    // We are running 30 sec wait, want 60.
            theBlinker.setPeriod(60000);              // Setting the blinker 60 seconds.
            mode = 60;                                // We are now in mode 60.
            digitalWrite(LED_1, LOW);
            digitalWrite(LED_2, LOW);
            digitalWrite(LED_3, LOW);
            digitalWrite(LED_4, LOW);
            digitalWrite(LED_5, HIGH);
         case 60 :                                    // We are running 30 sec wait, we want it off.
            theBlinker.setOnOff(false);               // Easy, just shut the thing off.
            mode = 0;                                 // And we are in mode 0;
            digitalWrite(LED_1, LOW);
            digitalWrite(LED_2, LOW);
            digitalWrite(LED_3, LOW);
            digitalWrite(LED_4, LOW);
            digitalWrite(LED_5, LOW);

//Our loop..
void loop() {

   idle();                                      // Runs the things that like to run in the background.
   if (buttonState!=theButton.trueFalse()) {    // If the button has changed state..
      buttonChange();                           // We call the state changing function.
      buttonState = !buttonState;               // And we flip the button state.

Rather than this


change it to


in other words use a variable to provide the value.

Then have a look at the parse example in Serial Input Basics for a way to update the variable from data sent via Serial.


This is my project

  1. First of all, it is an intervalometer for the camera. With one button and one output for controlling shutter (using mosfet 2N 7000). With button, I want to change the interval between shutter released from 5 sec. to 60 sec. (5, 10, 20, 30, 60). It will have 4 LED to indicate which interval you have selected.
  2. Button counter I successfully made it work and LED indicator too.
  3. I want the program to use button counter value to choose millis() correct value like described in step 1. I need it to send 50 ms. pulse. Pulse needs to be HIGH (+5V) to control mosfet. So for an example, it needs to be like this:
    50ms (+5V) pulse then wait 5 seconds and do another pulse for 50ms and wait for 5 seconds and so on.

I am very sorry for that... I am new to Arduino, but I am trying to improve.

This is all done!

Now to add to my code I want it to read serial data. How can I do that?

I am very sorry for that... I am new to Arduino, but I am trying to improve.
This is all done!

the best way to "apologise" is to just show some own effort in improving.

You have been avised to read the input serial basics

So just start to read it. If you don't understand something re-link again to this text you are reading and quote the line you don't understand combined with your question

Or if your question is related to your code post your complete sketch combined with a concrete question.

It may take 10 or even 50 questions until your code works the way you want it. The amount of questions dosen't matter just show some own effort and some progress in your programming-skills.

best regards Stefan