*******************************************************************************************************
Assignment Name : Develop
an application using Beeglebone Black/ ARM Cortex A5 development board to
simulate the working of signal lights.
*******************************************************************************************************
import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
GPIO.setup("P9_15",GPIO.OUT)
GPIO.setup("P9_16",GPIO.OUT)
GPIO.setup("P9_23",GPIO.OUT)
GPIO.setup("P9_24",GPIO.OUT)
GPIO.setup("P8_11",GPIO.OUT)
GPIO.setup("P8_12",GPIO.OUT)
GPIO.setup("P8_13",GPIO.OUT)
GPIO.setup("P8_14",GPIO.OUT)
GPIO.setup("P8_17",GPIO.OUT)
GPIO.setup("P8_18",GPIO.OUT)
GPIO.setup("P8_7",GPIO.OUT)
GPIO.setup("P8_15",GPIO.OUT)
GPIO.setup("P8_16",GPIO.OUT)
GPIO.setup("P8_8",GPIO.OUT)
while True:
#--------------------------------------------------------LANE 1---------------------------------------------------------------
GPIO.output("P9_15",GPIO.HIGH)
GPIO.output("P9_24",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P8_11",GPIO.HIGH)
GPIO.output("P8_15",GPIO.LOW)
GPIO.output("P8_13",GPIO.LOW)
GPIO.output("P8_17",GPIO.LOW)
GPIO.output("P8_12",GPIO.LOW)
GPIO.output("P8_18",GPIO.HIGH)
GPIO.output("P8_14",GPIO.LOW)
GPIO.output("P8_16",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
GPIO.output("P9_16",GPIO.LOW)
GPIO.output("P9_23",GPIO.HIGH)
GPIO.output("P8_7",GPIO.LOW)
GPIO.output("P8_8",GPIO.LOW)
time.sleep(8)
num=1
while(num<6):
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_15",GPIO.LOW)
GPIO.output("P9_24",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_13",GPIO.LOW)
time.sleep(1)
num=num+1
#--------------------------------------------------------LANE 2---------------------------------------------------------------
GPIO.output("P9_15",GPIO.LOW)
GPIO.output("P9_24",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_11",GPIO.HIGH)
GPIO.output("P8_11",GPIO.LOW)
GPIO.output("P8_15",GPIO.HIGH)
GPIO.output("P8_13",GPIO.LOW)
GPIO.output("P8_17",GPIO.HIGH)
GPIO.output("P8_12",GPIO.LOW)
GPIO.output("P8_18",GPIO.HIGH)
GPIO.output("P8_14",GPIO.LOW)
GPIO.output("P8_16",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
GPIO.output("P9_16",GPIO.LOW)
GPIO.output("P9_23",GPIO.HIGH)
GPIO.output("P8_7",GPIO.LOW)
GPIO.output("P8_8",GPIO.LOW)
time.sleep(8)
num=1
while(num<6):
GPIO.output("P8_13",GPIO.HIGH)
GPIO.output("P8_15",GPIO.LOW)
GPIO.output("P8_17",GPIO.LOW)
time.sleep(1)
GPIO.output("P8_13",GPIO.LOW)
time.sleep(1)
num=num+1
#--------------------------------------------------------LANE 3---------------------------------------------------------------
GPIO.output("P9_15",GPIO.LOW)
GPIO.output("P9_24",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_11",GPIO.HIGH)
GPIO.output("P8_11",GPIO.HIGH)
GPIO.output("P8_15",GPIO.LOW)
GPIO.output("P8_13",GPIO.LOW)
GPIO.output("P8_17",GPIO.LOW)
GPIO.output("P8_12",GPIO.HIGH)
GPIO.output("P8_18",GPIO.LOW)
GPIO.output("P8_14",GPIO.HIGH)
GPIO.output("P8_16",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
GPIO.output("P9_16",GPIO.LOW)
GPIO.output("P9_23",GPIO.HIGH)
GPIO.output("P8_7",GPIO.LOW)
GPIO.output("P8_8",GPIO.LOW)
time.sleep(8)
num=1
while(num<6):
GPIO.output("P8_16",GPIO.HIGH)
GPIO.output("P8_12",GPIO.LOW)
GPIO.output("P8_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P8_16",GPIO.LOW)
time.sleep(1)
num=num+1
#--------------------------------------------------------LANE 4---------------------------------------------------------------
GPIO.output("P9_15",GPIO.LOW)
GPIO.output("P9_24",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_11",GPIO.HIGH)
GPIO.output("P8_11",GPIO.HIGH)
GPIO.output("P8_15",GPIO.LOW)
GPIO.output("P8_13",GPIO.LOW)
GPIO.output("P8_17",GPIO.LOW)
GPIO.output("P8_12",GPIO.LOW)
GPIO.output("P8_18",GPIO.HIGH)
GPIO.output("P8_14",GPIO.LOW)
GPIO.output("P8_16",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_14",GPIO.HIGH)
GPIO.output("P9_16",GPIO.LOW)
GPIO.output("P9_23",GPIO.LOW)
GPIO.output("P8_7",GPIO.LOW)
GPIO.output("P8_8",GPIO.LOW)
time.sleep(8)
num=1
while(num<6):
GPIO.output("P9_16",GPIO.HIGH)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_16",GPIO.LOW)
time.sleep(1)
num=num+1
#-------------------------------------------------------------------------------------------------------------------------------
Assignment Name : Develop
Robotics(stepper motor) Application using Beagle Board.
------------------------------------------------------------------------------------------------------------------------
Continuous
clockwise rotation
import
Adafruit_BBIO.GPIO as GPIO
import
time
#
8 stetter and 4 rotor
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
#
continuous clockwise rotation
while
True:
GPIO.output("P9_11",GPIO.LOW) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.HIGH)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
import
Adafruit_BBIO.GPIO as GPIO
import
time
#
8 stetter and 4 rotor
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
#
continuous anti-clockwise rotation
while
True:
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(1)
-------------------------------------------------------------------------------
Continuos
anti-clockwise rotation
import
Adafruit_BBIO.GPIO as GPIO
import
time
#
8 stetter and 4 rotor
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
#
continuous anti-clockwise rotation
while
True:
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(1)
-------------------------------------------------------------------------------
1
turn anti-clockwise rotation and 1 turn clockwise rotation
import
Adafruit_BBIO.GPIO as GPIO
import
time
#
8 stetter and 4 rotor
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
#
1 turn anti-clockwise rotation and 1 turn clockwise rotation | time delay=0.1 |
angle=360 degree
while
True:
cnt=0
while cnt<12:
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(0.1)
cnt=cnt+1
cnt =0
while cnt<12:
GPIO.output("P9_11",GPIO.LOW) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.HIGH)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
cnt=cnt+1
-------------------------------------------------------------------------------
1/2
turn anti-clockwise rotation and 1/2 turn clockwise rotation
import
Adafruit_BBIO.GPIO as GPIO
import
time
#
8 stetter and 4 rotor
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
#
1/2 turn anti-clockwise rotation and 1/2 turn clockwise rotation | time
delay=0.1 | angle=180 degree
while
True:
cnt=0
while cnt<24:
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(1)
cnt=cnt+1
cnt =0
while cnt<24:
GPIO.output("P9_11",GPIO.LOW)#
one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
GPIO.output("P9_11",GPIO.HIGH)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
cnt=cnt+1
-------------------------------------------------------------------------------
1/4
turn anti-clockwise rotation and 1/4 turn clockwise rotation
import
Adafruit_BBIO.GPIO as GPIO
import
time
#
8 stetter and 4 rotor
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
#
1/4 turn anti-clockwise rotation and 1/4 turn clockwise rotation | time
delay=0.1 | angle=90 degree
while
True:
cnt=0
while cnt<6:
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(0.1)
cnt=cnt+1
cnt =0
while cnt<6:
GPIO.output("P9_11",GPIO.LOW) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.HIGH)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
cnt=cnt+1
-------------------------------------------------------------------------------
HALF-STEP
-- anticlockwise continuos rotation
import
Adafruit_BBIO.GPIO as GPIO
import
time
#
8 stetter and 4 rotor
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
#
half - step
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
while
True:
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(1)
-------------------------------------------------------------------------------
HALF-STEP
-- 1/2 turn anticlockwise 1/2 turn clockwise rotation
import
Adafruit_BBIO.GPIO as GPIO
import
time
#
8 stetter and 4 rotor
GPIO.setup("P9_11",GPIO.OUT)
GPIO.setup("P9_12",GPIO.OUT)
GPIO.setup("P9_13",GPIO.OUT)
GPIO.setup("P9_14",GPIO.OUT)
#
half - step half turn anticlockwise half turn clockwise
#-----------------anti-clockwise-----------------------------------------------
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
cnt=0
while
cnt<11:
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(1)
cnt=cnt+1
GPIO.output("P9_11",GPIO.HIGH) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
#-----------------clockwise---------------------------------------------------
GPIO.output("P9_11",GPIO.LOW) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
cnt=0
while
cnt<11:
GPIO.output("P9_11",GPIO.LOW) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.HIGH)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.HIGH)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
cnt=cnt+1
GPIO.output("P9_11",GPIO.LOW) # one step angle = 3.72 degrees
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.LOW)
GPIO.output("P9_14",GPIO.HIGH)
time.sleep(0.1)
GPIO.output("P9_11",GPIO.LOW)
GPIO.output("P9_12",GPIO.LOW)
GPIO.output("P9_13",GPIO.HIGH)
GPIO.output("P9_14",GPIO.LOW)
time.sleep(1)
#-------------------------------------------------------------------------------------------------------------------------
Assignment Name :Pulse Width Modulation
--------------------------------------------------------------------------------------------------------------------------
import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.PWM as PWM
GPIO.setup("P8_7",GPIO.IN)
GPIO.setup("P8_8",GPIO.IN)
GPIO.setup("P8_9",GPIO.IN)
GPIO.setup("P8_10",GPIO.IN)
PWM.start("P8_13")
while True:
if(GPIO.input("P8_7")==0):
PWM.set_duty_cycle("P8_13",100)
elif(GPIO.input("P8_8")==0):
PWM.set_duty_cycle("P8_13",50)
elif(GPIO.input("P8_9")==0):
PWM.set_duty_cycle("P8_13",20)
elif(GPIO.input("P8_10")==0):
PWM.set_duty_cycle("P8_13",0)
PWM.stop()
#-------------------------------------------------------------------------------------------------------------------------
Assignment Name : Develop a network based application by setting IP address on BeagleBoard ARM Cortex A5.
Assignment Name : Develop a network based application by setting IP address on BeagleBoard ARM Cortex A5.
--------------------------------------------------------------------------------------------------------------------------
client.py
import sys
import
socket
sc_client =
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sc_client.connect(("10.12.1.83",5541))
filename =
raw_input("Enter the name of file to download : ")
while True:
sc_client.send(filename)
sData = sc_client.recv(1024)
download = open(filename,"wb")
while sData:
download.write(sData)
sData = sc_client.recv(1024)
break
sc_client.close()
-------------------------------------------------------------------------------------------------------------------------
server.py
import
socket
import os
import sys
server_soc=socket.socket()
server_soc.bind(('10.12.1.83',
5541))
print
"Server in listening mode"
file_found=0
server_soc.listen(5)
while True:
client_soc, addr =
server_soc.accept()
print("Got a connection from
%s" % str(addr))
filename = client_soc.recv(1024)
for
file in os.listdir("."):
if
file == filename:
file_found
= 1
break
if
file_found == 0:
print
filename+" is not present on Beaglebone Server."
else:
print
filename+" File Found"
ClientFile
= open(filename,"r")
sRead = ClientFile.read(1024)
while sRead:
client_soc.send(sRead)
sRead
= ClientFile.read(1024)
print "File sent to
client!!"
break
client_soc.close()
server_soc.close()
-------------------------------------------------------------------------------------------------------------------------
OUTPUT
-------------------------------------------------------------------------------------------------------------------------
Server:
administrator@pm1:~$ cd Desktop
administrator@pm1:~/Desktop$ python Server.py
Server in listening mode
('10.12.0.252', 55994)
out.txt File Found
File sent to client.
administrator@pm1:~/Desktop$
Client:
student@pm18:~$ cd Desktop
student@pm18:~/Desktop$ python client.py
Enter the name of file to download : out.txt
student@pm18:~/Desktop$
#-------------------------------------------------------------------------------------------------------------------------
Assignment Name : Implement a Multi-threading application for echo server using socket programming in JAVA
--------------------------------------------------------------------------------------------------------------------------
Server
Program:
import
java.io.*;
import
java.net.*;
import
java.lang.Thread;
public class server1
{
public static void main (String[]
args) throws IOException
{
ServerSocket server = new ServerSocket(9999);
while (true)
{
Socket client = server.accept();
System.out.println("Server
Online");
InetAddress clientip = client.getInetAddress();
System.out.println("Client
connected " +clientip);
EchoHandler handler = new
EchoHandler(client);
handler.start();
}
}
}
class
EchoHandler extends Thread
{
Socket client;
EchoHandler (Socket client)
{
this.client
= client;
}
public void run ()
{
try
{
BufferedReader reader = new
BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter
writer = new
PrintWriter(client.getOutputStream(), true);
InetAddress Clientip
= client.getInetAddress();
writer.println("[type
'bye' to disconnect]");
while
(true)
{
String
line = reader.readLine();
if
(line.trim().equals("bye"))
{
writer.println("bye!");
break;
}
writer.println("[echo]
"+line);
System.out.println("Message
send by client"+Clientip);
System.out.println(line);
}
}
catch (Exception e)
{
System.err.println("Exception
caught: client disconnected.");
}
finally
{
try
{
client.close();
System.out.println("Client
Connection Close "+client.getInetAddress().toString());
}
catch
(Exception e )
{
;
}
}
}
}
//------------------------------------------------------------------------------------------------------------------------
Client
Program:
import
java.io.*;
import
java.net.*;
public
class client
{
public static void main(String[]
args) throws IOException
{
System.out.println("Please
Enter IP of SERVER");
BufferedReader IP = new
BufferedReader(new InputStreamReader(System.in));
String ServerIP=
IP.readLine();
Socket s = new
Socket(ServerIP, 9999);
BufferedReader r = new BufferedReader(new
InputStreamReader(s.getInputStream()));
PrintWriter w = new PrintWriter(s.getOutputStream(),
true);
BufferedReader con = new
BufferedReader(new InputStreamReader(System.in));
String line;
do
{
line =
r.readLine();
if ( line !=
null )
System.out.println(line);
System.out.println("Enter
Message : ");
line =
con.readLine();
w.println(line);
}
while (
!line.trim().equals("bye") );
}
}
-------------------------------------------------------------------------------------------------------------------------
OUTPUT
-------------------------------------------------------------------------------------------------------------------------
Server Side:
administrator@112A-12:~/Desktop$
javac server.java
administrator@112A-12:~/Desktop$
java server
Server
Online
Client
connected /10.10.0.106
Message
Sent By Client /10.10.0.106
hii
Message
Sent By Client /10.10.0.106
hello
Client
Connection Close /10.10.0.106
Client Side:
administrator@112A-11:~/Desktop$
javac client.java
administrator@112A-11:~/Desktop$
java client
Please
Enter IP of SERVER
10.10.0.100
[type
'bye' to disconnect]
Enter
Message :
hiiadministrator@112A-11:~/Desktop$
javac client.java
administrator@112A-11:~/Desktop$
java client
Please
Enter IP of SERVER
10.10.0.100
[type
'bye' to disconnect]
Enter
Message :
hii
[echo]
hii
Enter
Message :
hello
[echo]
hello
Enter
Message :
bye
administrator@112A-11:~/Desktop$
administrator@112A-11:~/Desktop$
[echo]
hii
Enter
Message :
hello
[echo]
hello
Enter
Message :
bye
administrator@112A-11:~/Desktop$
//------------------------------------------------------------------------------------------------------------------------
Assignment Name : Develop an application using Beeglebone Black/ ARM Cortex A5 development board to simulate the operations of LIFT.
Assignment Name : Develop an application using Beeglebone Black/ ARM Cortex A5 development board to simulate the operations of LIFT.
--------------------------------------------------------------------------------------------------------------------------
import
Adafruit_BBIO.GPIO as GPIO
import time
led_pins =
['P9_23', 'P9_24', 'P9_11', 'P9_12', 'P9_13', 'P9_14', 'P9_15', 'P9_16']
seg =
['P8_11', 'P8_12', 'P8_13', 'P8_14', 'P8_15', 'P8_16', 'P8_17', 'P8_18']
switch =
['P8_7', 'P8_8', 'P8_9', 'P8_10']
zero =
['P8_11', 'P8_12', 'P8_13', 'P8_14', 'P8_15', 'P8_16']
one =
['P8_12', 'P8_13']
two =
['P8_11', 'P8_12', 'P8_14', 'P8_15', 'P8_17']
three =
['P8_11', 'P8_12', 'P8_13', 'P8_14', 'P8_17']
for i in range(len(led_pins)):
GPIO.setup(led_pins[i], GPIO.OUT)
GPIO.setup(seg[i], GPIO.OUT)
for j in
range(len(switch)):
GPIO.setup(switch[j], GPIO.IN)
def
led_clear():
for i in range(len(led_pins)):
GPIO.output(led_pins[i],
GPIO.LOW)
def
seg_clear():
for i in range(len(seg)):
GPIO.output(seg[i],
GPIO.HIGH)
def
seg_disp(b):
if b == 0:
seg_clear()
for i in
range(len(zero)):
GPIO.output(zero[i],
GPIO.LOW)
if b == 1:
seg_clear()
for j in
range(len(one)):
GPIO.output(one[j],
GPIO.LOW)
if b == 2:
seg_clear()
for k in
range(len(two)):
GPIO.output(two[k],
GPIO.LOW)
if b == 3:
seg_clear()
for l in
range(len(three)):
GPIO.output(three[l],
GPIO.LOW)
def
ledUp(current):
if current == 0:
led_clear()
GPIO.output("P9_23",GPIO.HIGH)
elif current == 1:
led_clear()
GPIO.output("P9_16",GPIO.HIGH)
elif current == 2:
led_clear()
GPIO.output("P9_14",GPIO.HIGH)
elif current == 3:
led_clear()
GPIO.output("P9_12",GPIO.HIGH)
def
ledDown(current):
if current == 0:
led_clear()
GPIO.output("P9_24",GPIO.HIGH)
elif current == 1:
led_clear()
GPIO.output("P9_15",GPIO.HIGH)
elif current == 2:
led_clear()
GPIO.output("P9_13",GPIO.HIGH)
elif current == 3:
led_clear()
GPIO.output("P9_11",GPIO.HIGH)
currentLevel
= 0
goToLevel =
0
seg_disp(0)
led_clear()
while True:
if (GPIO.input("P8_10") ==
0):#0
print 'Button 0'
goToLevel = 0
if (currentLevel >
goToLevel):
while
(currentLevel >= goToLevel):
seg_disp(currentLevel)
ledDown(currentLevel)
time.sleep(1)
currentLevel
-= 1
currentLevel
+= 1
elif (GPIO.input("P8_8")
== 0):#1
print 'Button 1'
goToLevel = 1
if (currentLevel <
goToLevel):
while
(currentLevel <= goToLevel):
seg_disp(currentLevel)
ledUp(currentLevel)
time.sleep(1)
currentLevel
+= 1
currentLevel
-= 1
elif (currentLevel >
goToLevel):
while
(currentLevel >= goToLevel):
seg_disp(currentLevel)
ledDown(currentLevel)
time.sleep(1)
currentLevel
-= 1
currentLevel
+= 1
elif (GPIO.input("P8_9")
== 0):#2
print 'Button 2'
goToLevel = 2
if (currentLevel <
goToLevel):
while
(currentLevel <= goToLevel):
seg_disp(currentLevel)
ledUp(currentLevel)
time.sleep(1)
currentLevel
+= 1
currentLevel
-= 1
elif (currentLevel >
goToLevel):
while
(currentLevel >= goToLevel):
seg_disp(currentLevel)
ledDown(currentLevel)
time.sleep(1)
currentLevel
-= 1
currentLevel
+= 1
elif (GPIO.input("P8_7")
== 0):#3
print 'Button 3'
goToLevel = 3
if (currentLevel <
goToLevel):
while
(currentLevel <= goToLevel):
seg_disp(currentLevel)
ledUp(currentLevel)
time.sleep(1)
currentLevel
+= 1
currentLevel
-= 1
#-------------------------------------------------------------------------------------------------------------------------