Popular posts from this blog
day 22
Python code import serial #Import Serial Library from visual import * #Import all the vPython library arduinoSerialData = serial.Serial('COM3', 9600) #Create an object for the Serial port. Adjust 'com11' to whatever port your arduino is sending to. measuringRod = cylinder( axis=(0,0,10),radius= .5, length=6, color=color.yellow, pos=(-3,0,0)) lengthLabel = label(pos=(0,0,5), text='Target Distance is: ', box=false, height=10) orientation = 0 x = 0 y = 1 z = 2 while (1==1): #Create a loop that continues to read and display the data rate(20)#Tell vpython to run this loop 20 times a second if (arduinoSerialData.inWaiting()>0): #Check to see if a data point is available on the serial port myData = arduinoSerialData.readline() #Read the distance measure as a string myData = myData.strip() mylist = myData.split(',') ax = mylist[x] ay = mylist[y] az = mylist[z] #print ax,ay,az #Print...
day 18
LAB: const int BUTTON_INT = 0; const int RED = 11; const int GREEN = 10; const int BLUE = 9; volatile int selectedLED = RED; void setup() { pinMode (RED, OUTPUT); pinMode (GREEN, OUTPUT); pinMode (BLUE, OUTPUT); attachInterrupt (BUTTON_INT, swap, RISING); } void swap() { analogWrite (selectedLED, 0); if (selectedLED == GREEN) { selectedLED = RED; } else if(selectedLED == RED) { selectedLED = BLUE; } else if(selectedLED == BLUE) { selectedLED = GREEN; } } void loop() { for(int i = 0; i<256; i++) { analogWrite(selectedLED, i); delay(10); } for(int i = 255; i >= 0; i--) { analogWrite(selectedLED, i); delay(10); } } Homework: //number of tsunamis the year of the largest wave #include <...

Comments
Post a Comment