This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var serial; // variable to hold an instance of the serialport library | |
| var portName = 'dev/cu.usbmodem97'; // fill in your serial port name here | |
| var inData; // for incoming serial data | |
| function setup() { | |
| createCanvas(400, 300); | |
| serial = new p5.SerialPort(); // make a new instance of the serialport library | |
| serial.on('list', printList); // set a callback function for the serialport list event | |
| serial.on('connected', serverConnected); // callback for connecting to the server | |
| serial.on('open', portOpen); // callback for the port opening |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| Serial.begin(9600); // initialize serial communications | |
| } | |
| void loop() { | |
| int flexSensor = analogRead(A0); // read the input pin | |
| int mappedflexSensor = map(flexSensor, 0, 1023, 0, 255); // remap the flex Sensor value to fit in 1 byte | |
| Serial.println(mappedflexSensor); // print it out the serial port | |
| delay(1); // slight delay to stabilize the ADC | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| Serial.begin(9600); // initialize serial communications | |
| } | |
| void loop() { | |
| int flexSensor = analogRead(A0); // read the input pin | |
| int mappedflexSensor = map(flexSensor, 0, 1023, 0, 255); // remap the flex sensor value to fit in 1 byte | |
| Serial.write(mappedflexSensor); // print it out the serial port | |
| delay(1); // slight delay to stabilize the ADC (analog to digital converter on the microcontroller | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let serial; //Variable to hold instance of the serialport library; | |
| function setup() { | |
| serial = new p5.SerialPort(); //Make a new instance of the serialport library | |
| serial.on('list', printList); //Set a call back function for the serial port list | |
| serial.list(); //List the serial ports | |
| } | |
| //Get the list of serial ports |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var x = 100; | |
| var y = 100; | |
| var facesize = 150; | |
| var firstpointx = 102; | |
| var firstpointy = 128; | |
| var secondpointx = 100; | |
| var secondpointy = 145; | |
| function setup() { | |
| createCanvas(400, 400); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "pitches.h" | |
| //Make a sketch that plays a note on each sensor when | |
| //the sensor is above a given threshold. | |
| // | |
| //Start with a few constants: one for the threshold, | |
| //one for the speaker pin number, and one for the | |
| //duration of each tone. To make this instrument work, | |
| //you need to know what note corresponds to each sensor. | |
| //Include pitches.h as you did above, then make an array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Servo.h> | |
| //First, find out the range of your sensor by using analogRead() | |
| //to read the sensor and printing out the results. | |
| //Now, map the result of the analog reading to a range from 0 to 179, | |
| //which is the range of the sensor in degrees. Store the mapped | |
| //value in a local variable called servoAngle. | |
| //Finally, add the servo library at the beginning of your code, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Description: A sketch of random circles, squares that | |
| //follow your cursor, and a background the changes when | |
| //you press the mouse | |
| //Notes and Questions: | |
| //Organizing code by creating javascript objects | |
| //?Are these overridden later in my code when I give these new | |
| //limits? |
NewerOlder