0% found this document useful (0 votes)
22 views2 pages

Include

The document describes code for controlling servos and reading input from a PSX controller. It includes defining libraries, pins, and variables. It then sets up the pins and attaches servos before reading controller input and mapping values to motor movements.

Uploaded by

Maarif Didik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Include

The document describes code for controlling servos and reading input from a PSX controller. It includes defining libraries, pins, and variables. It then sets up the pins and attaches servos before reading controller input and mapping values to motor movements.

Uploaded by

Maarif Didik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <Servo.

h>
#include <Psx.h>
#define dataPin A0
#define cmndPin A1
#define attPin A3
#define clockPin A4

#define pwm2 5
#define pwm3 6

Psx Psx; // pengenalan nama library


Servo kanan;
Servo kiri;
unsigned int data = 0; // untuk menyimpan respon data

void setup()
{
Psx.setupPins(dataPin, cmndPin, attPin, clockPin, 10);
badan.attach(11);
kiri.attach(10);
kanan.attach(9);

pinMode (pwm1, OUTPUT);


pinMode (pwm2, OUTPUT);
pinMode (pwm3, OUTPUT);
pinMode (pwm4, OUTPUT);
Serial.begin(9600);
}

void loop() {
data = Psx.read();
Serial.println(data);
if (data == 8) //maju kencang
{

}
else if (data == 1) //kiri kencang
{

}
else if (data == 2) //mundur kencang
{

}
else if (data == 4) //kanan kencang
{

}
else if (data == 256)
{

else if (data == 2048)


{

}
else if (data == 16384) //tombol R2
{

}
else if (data == 4096) //tombol R1
{

else if (data == 1024)


{

else if (data == 0) //berhenti


{

}
else if (data == 512)
{

else if (data == 8192)


{

}
else if (data == 32768)
{

}
delay(100);
}

You might also like