1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-08 11:22:40 +03:00

Committing individual examples instead of one .zip

This commit is contained in:
David A. Mellis
2006-04-26 11:09:43 +00:00
parent 9dbfe53224
commit 260c5d5ee1
39 changed files with 2057 additions and 16 deletions

View File

@@ -0,0 +1,71 @@
/* Inputs to PD
* -------------------
*
* This program sends data from a bunch of inputs to PD
* over the serial port (works on PC: Windows and Linux, and MAC)
* The code reads 3 potentiometers and 6 buttons plugged to Arduino
* input and sends the data back to the computer.
*
* On the other side there will be a PureData sketch running
* comport2000 and will use the data to change a sound or video
* file properties.
*
* The buttons will be characterized with '1' or '0' depending on
* their state, while potentiometers will be characterized with a
* 10 bits integer in the range 0..1024
*
* The first sensor will be marked with 'A' (ascii 65), the second
* with 'B', and so on. The end of sensor reading is marked with
* the characters EOLN (ascii 10).
*
* (cleft) 2005 DojoDave for K3
*
* @author: David Cuartielles
* @context: ID3 - K3 - MAH - Sweden
*/
int ledPin = 13; // declare the pin with the LED
int potentioMeter = 0; // declare the analog pin for the potentiometer
int pushButton = 0; // declare the value
int writeChar = 65; // declare the first reading as 'A'
int value = 0; // value to read the different sensors
int ledStatus = LOW; // status of the LED
void setup() {
pinMode(ledPin, OUTPUT); // declare the LED as output
Serial.begin(9600); // intitialize the serial port
}
void loop() {
writeChar = 65; //Sets the sensor idendifier
// character back to 'A'.
// start reading the potentiometers on the analog pins
for(potentioMeter=0;potentioMeter<3;potentioMeter++){
Serial.print(writeChar, BYTE);
Serial.print(analogRead(potentioMeter));
Serial.println();
writeChar = writeChar + 1;
delay(10);
}
// read the pushbuttons
for(pushButton=2;pushButton<8;pushButton++){
Serial.print(writeChar, BYTE);
value = digitalRead(pushButton); // reads the value at a digital input
if (value)
{
Serial.print('0');
} else {
Serial.print('1');
}
Serial.println();
writeChar = writeChar + 1;
delay(10);
}
delay(100);
ledStatus = !ledStatus;
digitalWrite(ledPin, ledStatus);
}

View File

@@ -0,0 +1,37 @@
/* Potentiometer to PD
* -------------------
*
* This program sends data from a potentiometer to PD
* over the serial port (works in Windows and Linux, MAC?)
* The code reads a potentiometer plugged to an analog
* input and sends the data as a byte back to the computer.
*
* On the other side there will be a PureData sketch running
* comport2000 and will use the data to change a sound file
* properties.
*
* In order to make the data transfer as simple as possible
* we will only send a byte back to the computer, what means
* that the data coming from the ADC will be divided by 4.
*
* (cleft) 2005 DojoDave for K3
*
* @author: David Cuartielles
* @context: ID3 - K3 - MAH - Sweden
*/
int ledPin = 13;
int potPin = 0;
int ledStatus = LOW;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
Serial.print(analogRead(potPin)/4, BYTE);
delay(100);
ledStatus = !ledStatus;
digitalWrite(ledPin, ledStatus);
}

View File

@@ -0,0 +1,31 @@
/* Two Potentiometers
* ------------------
*
* This program reads two potentiometers and
* sends the data to the computer. It combines
* both with PD or Processing
*
* (cleft) 2005 David Cuartielles for DojoCorp
* @author: D. Cuartielles
* @credit: Nima and Greg
* @date: 2005-11-18
* @location: SFU, Vancouver, Canada
*/
int potPin1 = 0;
int potPin2 = 1;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print('A');
Serial.print(analogRead(potPin1));
Serial.println();
delay(500);
Serial.print('B');
Serial.print(analogRead(potPin2));
Serial.println();
delay(500);
}