Pick to Light Project 2 WiFi




In the second project in my pick to light, I am using WIFI to pass the data between PC and Arduino.

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000

× 1
LED (generic)
LED (generic)
× 2
Jumper wires (generic)
Jumper wires (generic)
× 1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
× 1
Resistor 10k ohm
Resistor 10k ohm
× 1
Resistor 330 ohm
Resistor 330 ohm
× 4
Breadboard (generic)
Breadboard (generic)
× 1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
× 1
General Purpose Transistor NPN
General Purpose Transistor NPN
× 1

Story

READ  BBC Micro Online
Python Script to be run.
## load the necessary libraries
import csv
import socket
import time
import sys

UDP_IP = "192.168.1.119" ## the ip of our Arduino
UDP_PORT = 2390 ## the port we wish to communicate on

print("UDP target IP:", UDP_IP) ## display ip to user
print("UDP target port:", UDP_PORT) ## display port to user

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # create a socket


time.sleep(5)
##open csv file and read it in one line at a time
with open('sequence1.txt') as csvDataFile: 
    csvReader = csv.reader(csvDataFile)
    for row in csvReader: ##for each line do the following
        myseq = row[] ##read in the sequence number
        mystate = row[1] ##read in the bin number
        myrow = row[] + row[1]
        print("Current sequence being picked ",myseq,"from ", mystate)
        sock.sendto(bytes(myrow, "utf-8"), (UDP_IP, UDP_PORT)) # send seq and bin number
        data = "" # set data to blank to enter while loop i=until data is received
        while data == "": # until data is received keep looping through
            (data, addr) = sock.recvfrom(1024) # set data to data received from socket
            mytest = data.decode( "utf-8") #set mytest to equal value received over socket
            print ("picked = ", mytest) # print the value received
            if mytest != myseq: # test what has ben received matches what was expected i.e. last seq sent
                print ("there is a sequence fault at sequence", mytest) # display message to indicate a fault
                sys.exit() #end program execution if fault exists

Sequence

Plain text

Sequence file for the python program
0001,Bin1
0002,Bin2
0003,Bin1
0004,Bin2
0005,Bin1
0006,Bin2
0007,Bin1
0008,Bin2
0009,Bin1
0010,Bin2
0011,Bin1
0012,Bin2
0013,Bin1

 

Source : Pick to Light Project 2 WiFi




Leave a Comment

*
= 5 + 6

(Spamcheck Enabled)

Read previous post:
GYRFALCON LAUNCHES SECOND-GEN AI ACCELERATOR CHIP
GYRFALCON LAUNCHES SECOND-GEN AI ACCELERATOR CHIP

Lightspeeur 2803 – a follow on to the Lightspeeur 2801S ASIC – enables upgrading of existing data center hardware to speed AI...

Close
Scroll to top