errors beating my head on wall

I didnt write this , got it from instructables. I know very little about C++ I can write PLC ladder logic . Here is my code :

any help would be greatly appreciated

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
#include <DFR_Key.h>
#include <multiCameraIrControl.h>

/* Shapespeare Scanner by Whitney Potter

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

Controls
SELECT: Start/Stop automatic scan.
LEFT: Trigger exposure and advance one unit clockwise.
RIGHT: Step one unit clockwise without triggering camera.
DOWN: Step one unit counter clockwise without triggering camera.
UP: Cycle through options for number of exposures per revolution.

*/

#include <LiquidCrystal.h>
#include <Keyboard.h>
#include <Stepper.h>
#include <DFR_Key.h>

const int stepsPerRevolution = 200 * 64; // change this to fit the number of steps per revolution for your motor

Stepper myStepper(stepsPerRevolution, 20, 21); // initialize stepper
// Enable pin is 19. Step pin is 20. Direction pin is 21

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); //pin assignments for SainSmart LCD Keypad Shield

DFR_Key keypad; // initialize keypad

int localKey = 0;
int lastKey = 0;
int keyChange = 1; //set true when key is released. Prevents double triggers.
int stepChoices [] = {25, 50, 75, 100, 200}; //different numbers of exposures per revolution which may be selected. Higher number = smaller angle change
int stepIndex = 0; // count exposures starting at 1
int numChoices = 5; //number of step choices
int runFlag = 0; //is scanner running
int stepCount = 1; // count exposures starting at 1
unsigned long startWait; //time we start the wait timer
unsigned long currentTime; // current time
const long preWait = 2000; // pre exposure pause in milis. Allows the specimen to settle before exposure.
const long postWait = 2000; // post exposure pause in milis. Allows time for the exposure to finish before moving.
int waitFlag = 0; // 0=ready to move 1=pre-exposure wait 2=post-exposure wait
int CanonCamera = (53); //change Nikon to any other supported brand

void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Shapespeare Scanner");
delay(2500);
lcd.clear();

// set the speed at 60 rpm:
myStepper.setSpeed(2);

pinMode(19, OUTPUT); //enable pin
digitalWrite(19, HIGH);

}

void loop() {

//
lcd.setCursor(0, 0);
lcd.print("Steps:");
lcd.setCursor(6, 0);
lcd.print(" ");
lcd.setCursor(6, 0);
lcd.print(stepChoices[stepIndex]);
lcd.setCursor(0, 1);
if (runFlag == 1)
{
lcd.print("run ");

}
else
{
lcd.print("stop ");
}

localKey = keypad.getKey(); // read keypad

if (localKey != SAMPLE_WAIT)
{

if (localKey == 0) // key has been released
{
keyChange = 1; // the next key data represents a new key press
}

if (localKey == 1 && keyChange == 1) //select=start sequence
{
if (runFlag == 0 && keyChange == 1)
{
runFlag = 1;
waitFlag = 0;
keyChange = 0;

}
if (runFlag == 1 && keyChange == 1)
{
runFlag = 0;
//stepCount = 1; //uncomment to reset stepCount every time the auto scan is stopped.
keyChange = 0;

}

if (localKey == 2 && keyChange == 1) //left=manual mode
{
keyChange = 0;
lcd.setCursor(0, 1);
lcd.print("manual");
CanonCamera shutterNow() ;//trigger exposure
delay (postWait); //wait for exposure to complete
digitalWrite(19, LOW); // activate stepper driver
myStepper.step(stepsPerRevolution / stepChoices[stepIndex]); // advance stepper
digitalWrite(19, HIGH); // deactivate stepper driver to save power, heat and noise
stepCount ++;

}

if (localKey == 3 && keyChange == 1 && runFlag == 0) //up cycle through angle choices
{
keyChange = 0;
if (stepIndex < numChoices - 1)
{
stepIndex ++;
}
else
{
stepIndex = 0;
}
}

if (localKey == 4 && keyChange == 1) //down
{
keyChange = 0;
lcd.setCursor(0, 1);
lcd.print("CCW step");
digitalWrite(19, LOW);
myStepper.step(-stepsPerRevolution / stepChoices[stepIndex]);
digitalWrite(19, HIGH);

}

if (localKey == 5 && keyChange == 1) //right
{
keyChange = 0;
lcd.setCursor(0, 1);
lcd.print("CW step");
digitalWrite(19, LOW);
myStepper.step(stepsPerRevolution / stepChoices[stepIndex]);
digitalWrite(19, HIGH);

}

}

if (runFlag == 1) //sequence is running
{

if (stepCount > stepChoices[stepIndex]) //the revolution is complete.
{
runFlag = 0; // stop sequence
lcd.setCursor(9, 1);
lcd.print("Done ");
}

//This interrupt based time delay allows us to still receive keypad input during the delay

currentTime = millis();

if (waitFlag == 0) // advance stepper and start wait timer
{
startWait = millis();
waitFlag = 1; // start preshutter wait
lcd.setCursor(9, 1);
lcd.print("Exp#: ");
lcd.setCursor(13, 1);
lcd.print(stepCount);

digitalWrite(19, LOW); //activate stepper driver
myStepper.step(stepsPerRevolution / stepChoices[stepIndex]); //advance stepper
digitalWrite(19, HIGH); //deactivate stepper driver

}

if (waitFlag == 1) // when preshutter wait expires trigger shutter
{

if (currentTime - startWait >= preWait) //wait time has expired
{

CanonCamera shutterNow() ; // trigger shutter
startWait = millis(); // restart wait timer
waitFlag = 2; // initiate post shutter wait
stepCount ++;
}

if (waitFlag == 2) // wait after triggering shutter before moving motor
{

if (currentTime - startWait >= postWait) //wait time has expired
{
waitFlag = 0; //done waiting
}
}

}
}
}

You forgot to post the errors.
You forgot to use code tags.

got it from instructables

INCOMING!

Note the use of code tags

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
#include <DFR_Key.h>
#include <multiCameraIrControl.h>

Have you installed each of these libraries ?

Welcome to the forum. Please read the posts at the top of the forum about how to properly post your code using code tags. It helps others help you.

You also did not say how the above code is not working. Does it compile? Does it not do what you expect? What do you expect it to do and how does that differ from what it does do?

One observation: This code is flawed

if (runFlag == 0 && keyChange == 1)
{
  runFlag = 1;
  waitFlag = 0;
  keyChange = 0;
}
if (runFlag == 1 && keyChange == 1)
{
  runFlag = 0;
  //stepCount = 1;  //uncomment to reset stepCount every time the auto scan is stopped.
  keyChange = 0;
}

If the first if() is true, you change runFlag to 1 which means the second if() will be true and you set runFlag back to 0. Probably not what you want

jastone:
I didnt write this , got it from instructables.

I don't know about other areas of endeavor, but just about every coding-related project I've seen on Instructables is crap.

I apologize for not knowing about tags.

CanonCamera shutterNow() ; // trigger shutter
startWait = millis(); // restart wait timer
waitFlag = 2; // initiate post shutter wait
stepCount ++;

error is :

expected ';' before shutterNow

I had a few other errors before this ie:

something not declared

I have checked and the in the adafruit these are added. They were not at first causing some of the other errors so I installed them there.

thank all of you for your help, I am not an Arduino person but learning slowly.

The code is supposed to simply run a stepper motor and fire a led to trigger the IR remote on camera at each step of motor. simple right!!

Post the code.
In code tags.

Post all the error messages.

Please provide a link to where you got the code

Your code

CanonCamera  shutterNow() ; // trigger shutter

original code

  Camera.shutterNow();  //trigger exposure

Spot the difference

now have error:

request for member shutterNow in CanonCamera which is a non class type int

How does this stuff happen with cut-and-paste?

I dont know but evedintly it does, hell, I wouldnt know to seperate those words to begin with or make changes

I just dont understand the language , maybe i should buy a micrologix 1500 and do it that way. Seemed cool and pretty simple when I saw the instructable. oh well

jastone:
now have error:

request for member shutterNow in CanonCamera which is a non class type int

original code

Nikon Camera(53);  //change Nikon to any other supported brand

your code

int CanonCamera = (53); //change Nikon to any other supported brand

Again, spot the difference

Please check your code very carefully against the original

ok, I dumped all that and redownloaded the code and installed, now I get error compiling arduino mega 2560.

I have 2560 selected in board , processor and port. can see it when I request info

now I get error compiling arduino mega 2560.

And we've got to guess what it is?

Such fun!

Not.

Are we enjoying this thread yet ?

I did see the difference you noted, I changed that , now that I have reloaded code maybe I can make some headway. I am guessing the instruction got messed up when I added Canon to camera and didnt realize I had augmented other part of line.

Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp: In member function 'void Adafruit_CircuitPlayground::playTone(uint16_t, uint16_t, bool)':

C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:201:3: error: 'PLLFRQ' was not declared in this scope

PLLFRQ = (PLLFRQ & 0xCF) | 0x30; // Route PLL to async clk

^

In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.19.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

from c:\program files\windowsapps\arduinollc.arduinoide_1.8.19.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

from C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground/Adafruit_Circuit_Playground.h:20,

from C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:30:

C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:202:31: error: 'PWM4A' was not declared in this scope

TCCR4A = _BV(COM4A0) | _BV(PWM4A); // Clear on match, PWMA on

^

C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:203:17: error: 'PWM4X' was not declared in this scope

TCCR4B = _BV(PWM4X) | scalebits; // PWM invert

^

C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:204:3: error: 'TCCR4D' was not declared in this scope

TCCR4D = 0; // Fast PWM mode

^

C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:205:3: error: 'TCCR4E' was not declared in this scope

TCCR4E = 0; // Not enhanced mode

^

C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:206:3: error: 'DT4' was not declared in this scope

DT4 = 0; // No dead time

^

C:\Users\jasto\Documents\Arduino\libraries\Adafruit_Circuit_Playground\Adafruit_CircuitPlayground.cpp:212:3: error: 'TC4H' was not declared in this scope

TC4H = hi1;

^

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.