Hi,
I doing a project where I have a 43PT-AR display controlling a stepper motor with a arduino and motor shield. To control the stepper motor I have a slider on the display which should control the position of the stepper motor. I'm having problems trying to write the arduino program in which it controls the motor. I got the display to show the value of the slider but I need to get that value sent to the stepper. Right now I'm getting an error that says 'class Stepper' has no member named 'write'. If anyone has any tips on has to get the display to control the stepper with the slider it would be greatly appreciated.
Thanks
#include <Stepper.h>
#include <genieArduino.h>
const int stepsPerRevolution = 100;
Stepper myStepper(stepsPerRevolution, 12,13);
// give the motor control pins names:
const int pwmA = 3;
const int pwmB = 11;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 12;
const int dirB = 13;
int Slider0 ;
int Stepperposition ;
Genie genie;
#define RESETLINE 4 // Change this if you are not using an Arduino Adaptor Shield Version 2 (see code below)
void setup()
{
Serial.begin(9600); //
genie.Begin(Serial); // Use Serial0 for talking to the Genie Library, and to the 4D Systems display
genie.AttachEventHandler(myGenieEventHandler); // Attach the user function Event Handler for processing events
pinMode(RESETLINE, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
digitalWrite(RESETLINE, 1); // Reset the Display via D4
delay(100);
digitalWrite(RESETLINE, 0); // unReset the Display via D4
delay (3500); //let the display start up after the reset (This is important)
}
void loop()
{
static long waitPeriod = millis();
myStepper.write(stepperposition);//
genie.DoEvents(); // This calls the library each loop to process the queued responses from the display
if (millis() >= waitPeriod)
{
waitPeriod = millis() + 50; // rerun this code to update Cool Gauge and Slider in another 50ms time.
}
}
void myGenieEventHandler(void)
{
genieFrame Event;
genie.DequeueEvent(&Event); // Remove the next queued event from the buffer, and process it below
int slider_val = 0;
//If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
{
if (Event.reportObject.object == GENIE_OBJ_SLIDER) // If the Reported Message was from a Slider
{
if (Event.reportObject.index == 0) // If Slider0 (Index = 0)
{
slider_val = genie.GetEventData(&Event); // Receive the event data from the Slider0
genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0, slider_val); // Write Slider0 value to to LED Digits 0
Stepperposition = genie.GetEventData(&Event);
}
}
}
}