Hello,
I am trying to make a ping pong ball launcher. I need a controller that allows me to move a stepper motor to three preset positions when I click a button on a webpage. I have made the Arduino code and circuit, and it works in that it responds when I send commands through the serial monitor.
Here is my current Arduino Code:
#include <Stepper.h>
int ledPin13 = 13; // the pin that the main LED is attached to
int incomingByte; // a variable to read incoming serial data into
Stepper myStepper(48, 9,10,11,12); //Set up 48 step stepper motor using pins 9,10,11,12void setup() {
Serial.begin(9600); // initialize serial communication
pinMode(ledPin13, OUTPUT); // initialize the green LED pin as an output
myStepper.setSpeed(60); // 60 rpms
}
void loop() {digitalWrite(ledPin13, HIGH); //Turn on the main LED
// see if there's incoming serial data:
if (Serial.available() > 0) {incomingByte = Serial.read(); // read the oldest byte in the serial buffer
//Preform the code to switch on or off the leds
if (incomingByte == '0') {
myStepper.step(14); // moves the stepper 14 steps forward
delay(300); // wait half a second.
myStepper.step(-14); // moves the stepper 14 steps backward
}
if (incomingByte == '1') {
myStepper.step(7); // moves the stepper 7 steps forward
}if (incomingByte == '2') {
myStepper.step(-7); // moves the stepper 7 steps backward
}}
}
I need a webpage that has three buttons. One that says "Fire" and sends the value "0" through serial, one that says "Rapid Fire On" and sends the value "1" through serial, and one that says "Rapid Fire Off" and sends the value "2" through serial.
Does anyone know how I should go about this? I am familiar with HTML, but not PHP.
Thanks,
Andrew