ModmataC  1.0
A C library for Arduino communication
pot_servo.c
#include <ModmataC.h>
int main() {
// start serial connection with arduino, given a port and baud rate
connectArduino("/dev/ttyACM0", 115200, 1);
int value = -1;
int led_val = 0;
pinMode(18, INPUT);
while(1) {
value = analogRead(18) / 1024.0 * 180;
if(value >= 0 && value <= 180)
{
servoWrite(6, value);
}
printf("%i\n", value);
}
}
int connectArduino(char *port, int baudRate, int id)
Definition: ModmataC.c:93
void pinMode(uint8_t pinNum, uint8_t mode)
Definition: ModmataC.c:121
void servoWrite(uint16_t pinNum, uint16_t input)
Definition: ModmataC.c:264
int analogRead(uint16_t pinNum)
Definition: ModmataC.c:212
void servoAttach(uint16_t pinNum)
Definition: ModmataC.c:237
#define INPUT
Definition: ModmataC.h:39