But this project was not stably yet sometimes it run but sometime it eror(board ATX).
Code
#include <ATX2.h> // เปลี่ ยนเป น ipst.h สํ าหรั บ IPST-SE และ popx2.h สํ าหรั บ POP-X2
byte x;
////////////////////////////////////////////////////////////////////
void forward() {
motor(4, 75);
motor(3, -75);
}
//======================================
void backward() {
motor(4, -75);
motor(3, 75);
}
//======================================
/*void ccw2() {
motor(3, -50);
motor(4, 50);
}
//======================================
void cw2() {
motor(3, 50);
motor(4, -50);
}*/
//======================================
void cw() {
motor(4, 75);
motor(3, 75);
}
//======================================
void ccw() {
motor(4, -75);
motor(3, -75);
}
//======================================
void wait() {
motor(4, 0);
motor(3, 0);
}
//======================================
void forward2() {
motor(4, 100);
motor(3, -100);
}
//======================================
void backward2() {
motor(4, -100);
motor(3, 100);
}
//======================================
void cw2() {
motor(4, 50);
motor(5, 50);
}
//======================================
void ccw2() {
motor(4, -50);
motor(5, -50);
}
//======================================
void abc() {
motor(2, 100);
}
//======================================
void lol() {
motor(2, -100);
}
//======================================
void st() {
motor(2, 0);
}
/*/======================================
void lol3() {
servo(2, 70);
delay(500);
servo(1, 130);
}*/
////////////////////////////////////////////////////////////////////
void setup()
{
setTextSize(2);
glcd(4, 0, "Wireless-X");
Serial1.begin(9600);
}
void loop()
{
while (Serial1.available() > 0)
x = Serial1.read();
if (x == 0x10)
{
forward();
abc();
}
else if (x == 0x80)
{
backward();
lol();
}
else if (x == 0x20)
{
ccw();
lol();
}
else if (x == 0x40)
{
cw();
lol();
}
else if (x == 0x04)
{
cw();
lol();
}
else if (x == 0x02)
{
ccw();
lol();
}
else if (x == 0x08)
{
backward2();
lol();
}
else if (x == 0x01)
{
forward2();
abc();
}
{
wait();
st();
}
}
byte x;
////////////////////////////////////////////////////////////////////
void forward() {
motor(4, 75);
motor(3, -75);
}
//======================================
void backward() {
motor(4, -75);
motor(3, 75);
}
//======================================
/*void ccw2() {
motor(3, -50);
motor(4, 50);
}
//======================================
void cw2() {
motor(3, 50);
motor(4, -50);
}*/
//======================================
void cw() {
motor(4, 75);
motor(3, 75);
}
//======================================
void ccw() {
motor(4, -75);
motor(3, -75);
}
//======================================
void wait() {
motor(4, 0);
motor(3, 0);
}
//======================================
void forward2() {
motor(4, 100);
motor(3, -100);
}
//======================================
void backward2() {
motor(4, -100);
motor(3, 100);
}
//======================================
void cw2() {
motor(4, 50);
motor(5, 50);
}
//======================================
void ccw2() {
motor(4, -50);
motor(5, -50);
}
//======================================
void abc() {
motor(2, 100);
}
//======================================
void lol() {
motor(2, -100);
}
//======================================
void st() {
motor(2, 0);
}
/*/======================================
void lol3() {
servo(2, 70);
delay(500);
servo(1, 130);
}*/
////////////////////////////////////////////////////////////////////
void setup()
{
setTextSize(2);
glcd(4, 0, "Wireless-X");
Serial1.begin(9600);
}
void loop()
{
while (Serial1.available() > 0)
x = Serial1.read();
if (x == 0x10)
{
forward();
abc();
}
else if (x == 0x80)
{
backward();
lol();
}
else if (x == 0x20)
{
ccw();
lol();
}
else if (x == 0x40)
{
cw();
lol();
}
else if (x == 0x04)
{
cw();
lol();
}
else if (x == 0x02)
{
ccw();
lol();
}
else if (x == 0x08)
{
backward2();
lol();
}
else if (x == 0x01)
{
forward2();
abc();
}
{
wait();
st();
}
}
#Made by M.1/3 at Satit PIM