Advertisement
SoapSuds

BeagleBone Turn on Custom LED

Mar 16th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. #Import Libraries
  2. ##################
  3.  
  4. #Tell python we need the library "os" for executing system commands directly
  5. import os
  6.  
  7. #Tell python we need the library "time" so we can use the "sleep" command
  8. import time
  9.  
  10.  
  11. i = 0;
  12. total_gpio = 96;
  13. while(i < total_gpio):
  14.     #Tell beaglebone we want to export this GPIO pin
  15.     os.system("echo "+str(i)+" > /sys/class/gpio/export");
  16.  
  17.     time.sleep(0.1);
  18.  
  19.     #Tell beaglebone we want to turn this gpio pin to OUTPUT
  20.     os.system("echo out > /sys/class/gpio/gpio"+str(i)+"/direction");
  21.  
  22.     #Tell beaglebone we want to turn this gpip pin on
  23.     os.system("echo 1 > /sys/class/gpio/gpio"+str(i)+"/value");
  24.     print "Last pin turned on was "+str(i)+"\n";
  25.    
  26.     time.sleep(0.1);
  27.     i = i + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement