import serial import time ser = serial.Serial('/dev/ttyUSB0',9600) # open serial port
print(ser.name) # check which port was really used time.sleep(4) ser.write(b'00') # write a string 09 ->fast forward a=ser.read print(a) time.sleep(2) ser.close() # close port
# read 8266
import serial import time ser = serial.Serial('/dev/ttyUSB1',115200) # open serial port
print(ser.name) # check which port was really used #time.sleep(4) #ser.write(b'00') # write a string 09 ->fast forward while True: a=ser.read() print(a) time.sleep(1) #ser.close() # close port
# 5 wire Steppermotor with driver uln2003 and i2c portmultiplexer pcf8574 # compile with # gcc -o go_step go_step.c # pcf8574 p0 -> uln2003 in1 and so on.
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
char Device[] = "/dev/i2c-1";
int fd;
int res;
int address = 0x20;
char Buffer[1];
int main(int argc, char** argv) // Programmstart
{
int i;
int t;
unsigned char ca[8];
ca[0]= 0x08;
ca[1]= 0x12;
ca[2]= 0x04;
ca[3]= 0x06;
ca[4]= 0x02;
ca[5]= 0x03;
ca[6]= 0x01;
ca[7]= 0x09;
fd = open(Device, O_RDWR);
if (ioctl(fd, I2C_SLAVE, address) < 0) // Set the port options and set the address of the device we wish to speak to
{
printf("Unable to get bus access to talk to slave\n");
exit(1);
}
//res = write(fd, argv[1], 1);
for(t=0; t<3600;t++)
{
i=0;
while ( i<8)
{
// printf("%d \n", i);
//sprintf(Buffer,"%d",i);
Buffer[0]=ca[i];
res = write(fd, Buffer, 1);
i++;
usleep(6000); //not less then 1500
}
}
close(fd);
return 0;
}