mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Merged master
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
<condition property="macosx"><os family="mac" /></condition>
|
||||
<condition property="windows"><os family="windows" /></condition>
|
||||
<condition property="linux"><os family="unix" /></condition>
|
||||
<condition property="linux32"><os family="unix" arch="i386" /></condition>
|
||||
<condition property="linux64"><os family="unix" arch="amd64" /></condition>
|
||||
|
||||
<condition property="platform"
|
||||
@ -15,7 +16,7 @@
|
||||
<condition property="platform"
|
||||
value="windows"><os family="windows" /></condition>
|
||||
<condition property="platform"
|
||||
value="linux"><os family="unix" arch="i386" /></condition>
|
||||
value="linux32"><os family="unix" arch="i386" /></condition>
|
||||
<condition property="platform"
|
||||
value="linux64"><os family="unix" arch="amd64" /></condition>
|
||||
|
||||
@ -281,9 +282,12 @@
|
||||
<replace file="macosx/work/Arduino.app/Contents/Info.plist"
|
||||
token="REVISION" value="${revision}" />
|
||||
|
||||
<exec executable="ditto" dir="macosx/work">
|
||||
<arg line="-c -k -rsrc . ../arduino-${version}-macosx.zip" />
|
||||
<exec executable="zip" dir="macosx/work">
|
||||
<arg line="-q -r ../arduino-${version}-macosx.zip ." />
|
||||
</exec>
|
||||
<!-- <exec executable="ditto" dir="macosx/work">
|
||||
<arg line="-c -k -rsrc . ../arduino-${version}-macosx.zip" />
|
||||
</exec> -->
|
||||
|
||||
<echo>
|
||||
=======================================================
|
||||
@ -388,6 +392,9 @@
|
||||
<param name="target.path" value="linux/work" />
|
||||
</antcall>
|
||||
|
||||
<copy todir="linux/work" file="linux/dist/arduino" />
|
||||
<chmod perm="755" file="linux/work/arduino" />
|
||||
|
||||
<copy todir="linux/work/hardware">
|
||||
<fileset dir="linux/dist" includes="tools/**" />
|
||||
</copy>
|
||||
@ -404,12 +411,28 @@
|
||||
<antcall target="linux-unzip-arm-toolchain" />
|
||||
</target>
|
||||
|
||||
<target name="linux32-build" depends="linux-build" description="Build linux (32-bit) version">
|
||||
<!-- Unzip AVR tools -->
|
||||
<exec executable="tar" dir="linux/work/hardware">
|
||||
<arg value="-xjf"/>
|
||||
<arg value="../../avr_tools_linux32.tar.bz2"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="linux64-build" depends="linux-build" description="Build linux (64-bit) version">
|
||||
<copy tofile="linux/work/hardware/tools/avrdude" file="linux/dist/tools/avrdude64" overwrite="true" />
|
||||
<copy tofile="linux/work/lib/librxtxSerial.so" file="linux/dist/lib/librxtxSerial64.so" overwrite="true" />
|
||||
|
||||
<chmod perm="755" file="linux/work/hardware/tools/avrdude" />
|
||||
|
||||
<!-- Unzip AVR tools -->
|
||||
<exec executable="tar" dir="linux/work/hardware">
|
||||
<arg value="-xjf"/>
|
||||
<arg value="../../avr_tools_linux64.tar.bz2"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="linux-run" depends="linux-build"
|
||||
<target name="linux32-run" depends="linux32-build"
|
||||
description="Run Linux (32-bit) version">
|
||||
<exec executable="./linux/work/arduino" spawn="false"/>
|
||||
</target>
|
||||
@ -477,7 +500,7 @@
|
||||
<!--
|
||||
<tar compression="gzip" basedir="linux/work"
|
||||
destfile="linux/arduino-${version}.tgz" />
|
||||
-->
|
||||
|
||||
<tar compression="gzip" destfile="linux/arduino-${version}-linux.tgz">
|
||||
<tarfileset dir="linux/work"
|
||||
prefix="arduino-${version}"
|
||||
@ -489,6 +512,18 @@
|
||||
<tarfileset file="linux/work/hardware/tools/avrdude" filemode="755"
|
||||
prefix="arduino-${version}/hardware/tools" />
|
||||
</tar>
|
||||
-->
|
||||
<move file="linux/work" tofile="linux/arduino-${version}" />
|
||||
|
||||
<exec executable="tar" dir="linux">
|
||||
<arg value="-z"/>
|
||||
<arg value="-c"/>
|
||||
<arg value="-f"/>
|
||||
<arg value="arduino-${version}-linux.tgz"/>
|
||||
<arg value="arduino-${version}"/>
|
||||
</exec>
|
||||
|
||||
<move file="linux/arduino-${version}" tofile="linux/work" />
|
||||
|
||||
<echo>
|
||||
=======================================================
|
||||
@ -499,6 +534,8 @@
|
||||
</echo>
|
||||
</target>
|
||||
|
||||
<target name="linux32-dist" depends="linux-dist"
|
||||
description="Build .tar.gz of linux version" />
|
||||
|
||||
<target name="linux64-dist" depends="linux-dist"
|
||||
description="Build .tar.gz of linux version" />
|
||||
@ -685,6 +722,7 @@
|
||||
<tarfileset dir="../"
|
||||
prefix="arduino-${version}"
|
||||
excludes="**/*.tgz,
|
||||
**/*.bz2,
|
||||
**/macosx/,
|
||||
**/windows/,
|
||||
**/work/,
|
||||
|
@ -34,6 +34,7 @@ my $wire = create_page('Wire.html', "$ARDUINO/Reference/Wire");
|
||||
my $sd = create_page('SD.html', "$ARDUINO/Reference/SD");
|
||||
my $servo = create_page('Servo.html', "$ARDUINO/Reference/Servo");
|
||||
my $spi = create_page('SPI.html', "$ARDUINO/Reference/SPI");
|
||||
my $mousekeyboard = create_page('MouseKeyboard.html', "$ARDUINO/Reference/MouseKeyboard");
|
||||
my $lcd = create_page('LiquidCrystal.html', "$ARDUINO/Reference/LiquidCrystal");
|
||||
my $ethernet = create_page('Ethernet.html', "$ARDUINO/Reference/Ethernet");
|
||||
my $serial = create_page('Serial.html', "$ARDUINO/Reference/Serial");
|
||||
@ -48,6 +49,8 @@ create_linked_pages($servo, qr!$ARDUINO/Reference/(Servo\w+)!, '%%.html')
|
||||
create_linked_pages($sd, qr!$ARDUINO/Reference/(SD\w+)!, '%%.html');
|
||||
create_linked_pages($sd, qr!$ARDUINO/Reference/(File\w+)!, '%%.html');
|
||||
create_linked_pages($spi, qr!$ARDUINO/Reference/(SPI\w+)!, '%%.html');
|
||||
create_linked_pages($mousekeyboard, qr!$ARDUINO/Reference/(Mouse\w+)!, '%%.html');
|
||||
create_linked_pages($mousekeyboard, qr!$ARDUINO/Reference/(Keyboard\w+)!, '%%.html');
|
||||
create_linked_pages($lcd, qr!$ARDUINO/Reference/(LiquidCrystal\w+)!, '%%.html');
|
||||
create_linked_pages($ethernet, qr!$ARDUINO/Reference/(Ethernet\w+)!, '%%.html');
|
||||
create_linked_pages($ethernet, qr!$ARDUINO/Reference/(Server\w+)!, '%%.html');
|
||||
|
BIN
build/linux/avr_tools_linux32.tar.bz2
Normal file
BIN
build/linux/avr_tools_linux32.tar.bz2
Normal file
Binary file not shown.
BIN
build/linux/avr_tools_linux64.tar.bz2
Normal file
BIN
build/linux/avr_tools_linux64.tar.bz2
Normal file
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
/*
|
||||
AnalogReadSerial
|
||||
Reads an analog input on pin 0, prints the result to the serial monitor.
|
||||
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
// the setup routine runs once when you press reset:
|
||||
void setup() {
|
||||
// initialize serial communication at 9600 bits per second:
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
// the loop routine runs over and over again forever:
|
||||
void loop() {
|
||||
// read the input on analog pin 0:
|
||||
int sensorValue = analogRead(A0);
|
||||
// print out the value you read:
|
||||
Serial.println(sensorValue);
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
24
build/shared/examples/01.Basics/Blink/Blink.ino
Normal file
24
build/shared/examples/01.Basics/Blink/Blink.ino
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
Blink
|
||||
Turns on an LED on for one second, then off for one second, repeatedly.
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
// Pin 13 has an LED connected on most Arduino boards.
|
||||
// give it a name:
|
||||
int led = 13;
|
||||
|
||||
// the setup routine runs once when you press reset:
|
||||
void setup() {
|
||||
// initialize the digital pin as an output.
|
||||
pinMode(led, OUTPUT);
|
||||
}
|
||||
|
||||
// the loop routine runs over and over again forever:
|
||||
void loop() {
|
||||
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(1000); // wait for a second
|
||||
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
|
||||
delay(1000); // wait for a second
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
DigitalReadSerial
|
||||
Reads a digital input on pin 2, prints the result to the serial monitor
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
// digital pin 2 has a pushbutton attached to it. Give it a name:
|
||||
int pushButton = 2;
|
||||
|
||||
// the setup routine runs once when you press reset:
|
||||
void setup() {
|
||||
// initialize serial communication at 9600 bits per second:
|
||||
Serial.begin(9600);
|
||||
// make the pushbutton's pin an input:
|
||||
pinMode(pushButton, INPUT);
|
||||
}
|
||||
|
||||
// the loop routine runs over and over again forever:
|
||||
void loop() {
|
||||
// read the input pin:
|
||||
int buttonState = digitalRead(pushButton);
|
||||
// print out the state of the button:
|
||||
Serial.println(buttonState);
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,19 +5,22 @@
|
||||
using the analogWrite() function.
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
*/
|
||||
|
||||
int led = 9; // the pin that the LED is attached to
|
||||
int brightness = 0; // how bright the LED is
|
||||
int fadeAmount = 5; // how many points to fade the LED by
|
||||
|
||||
// the setup routine runs once when you press reset:
|
||||
void setup() {
|
||||
// declare pin 9 to be an output:
|
||||
pinMode(9, OUTPUT);
|
||||
pinMode(led, OUTPUT);
|
||||
}
|
||||
|
||||
// the loop routine runs over and over again forever:
|
||||
void loop() {
|
||||
// set the brightness of pin 9:
|
||||
analogWrite(9, brightness);
|
||||
analogWrite(led, brightness);
|
||||
|
||||
// change the brightness for next time through the loop:
|
||||
brightness = brightness + fadeAmount;
|
||||
@ -29,3 +32,4 @@ void loop() {
|
||||
// wait for 30 milliseconds to see the dimming effect
|
||||
delay(30);
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
ReadAnalogVoltage
|
||||
Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
|
||||
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
// the setup routine runs once when you press reset:
|
||||
void setup() {
|
||||
// initialize serial communication at 9600 bits per second:
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
// the loop routine runs over and over again forever:
|
||||
void loop() {
|
||||
// read the input on analog pin 0:
|
||||
int sensorValue = analogRead(A0);
|
||||
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
|
||||
float voltage = sensorValue * (5.0 / 1023.0);
|
||||
// print out the value you read:
|
||||
Serial.println(voltage);
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Input Pullup Serial
|
||||
|
||||
This example demonstrates the use of pinMode(INPUT_PULLUP). It reads a
|
||||
digital input on pin 2 and prints the results to the serial monitor.
|
||||
|
||||
The circuit:
|
||||
* Momentary switch attached from pin 2 to ground
|
||||
* Built-in LED on pin 13
|
||||
|
||||
Unlike pinMode(INPUT), there is no pull-down resistor necessary. An internal
|
||||
20K-ohm resistor is pulled to 5V. This configuration causes the input to
|
||||
read HIGH when the switch is open, and LOW when it is closed.
|
||||
|
||||
created 14 March 2012
|
||||
by Scott Fitzgerald
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/InputPullupSerial
|
||||
|
||||
This example code is in the public domain
|
||||
|
||||
*/
|
||||
|
||||
void setup(){
|
||||
//start serial connection
|
||||
Serial.begin(9600);
|
||||
//configure pin2 as an input and enable the internal pull-up resistor
|
||||
pinMode(2, INPUT_PULLUP);
|
||||
pinMode(13, OUTPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
//read the pushbutton value into a variable
|
||||
int sensorVal = digitalRead(2);
|
||||
//print out the value of the pushbutton
|
||||
Serial.println(sensorVal);
|
||||
|
||||
// Keep in mind the pullup means the pushbutton's
|
||||
// logic is inverted. It goes HIGH when it's open,
|
||||
// and LOW when it's pressed. Turn on pin 13 when the
|
||||
// button's pressed, and off when it's not:
|
||||
if (sensorVal == HIGH) {
|
||||
digitalWrite(13, LOW);
|
||||
}
|
||||
else {
|
||||
digitalWrite(13, HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,6 +64,8 @@ void loop() {
|
||||
// wend from on to off:
|
||||
Serial.println("off");
|
||||
}
|
||||
// Delay a little bit to avoid bouncing
|
||||
delay(50);
|
||||
}
|
||||
// save the current state as the last state,
|
||||
//for next time through the loop
|
@ -9,7 +9,7 @@
|
||||
* 8-ohm speaker on digital pin 8
|
||||
|
||||
created 21 Jan 2010
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -41,5 +41,4 @@ void loop() {
|
||||
tone(8, notes[thisSensor], 20);
|
||||
}
|
||||
}
|
||||
Serial.println();
|
||||
}
|
@ -9,8 +9,8 @@
|
||||
* 4.7K resistor on analog 0 to ground
|
||||
|
||||
created 21 Jan 2010
|
||||
modified 30 Aug 2011
|
||||
by Tom Igoe
|
||||
modified 31 May 2012
|
||||
by Tom Igoe, with suggestion from Michael Flynn
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
@ -29,14 +29,15 @@ void loop() {
|
||||
int sensorReading = analogRead(A0);
|
||||
// print the sensor reading so you know its range
|
||||
Serial.println(sensorReading);
|
||||
// map the pitch to the range of the analog input.
|
||||
// map the analog input range (in this case, 400 - 1000 from the photoresistor)
|
||||
// to the output pitch range (120 - 1500Hz)
|
||||
// change the minimum and maximum input numbers below
|
||||
// depending on the range your sensor's giving:
|
||||
int thisPitch = map(sensorReading, 400, 1000, 100, 1000);
|
||||
int thisPitch = map(sensorReading, 400, 1000, 120, 1500);
|
||||
|
||||
// play the pitch:
|
||||
tone(9, thisPitch, 10);
|
||||
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* LED connected from digital pin 9 to ground
|
||||
|
||||
created 29 Dec. 2008
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -46,8 +46,8 @@ void loop() {
|
||||
Serial.print("\t output = ");
|
||||
Serial.println(outputValue);
|
||||
|
||||
// wait 10 milliseconds before the next loop
|
||||
// wait 2 milliseconds before the next loop
|
||||
// for the analog-to-digital converter to settle
|
||||
// after the last reading:
|
||||
delay(10);
|
||||
delay(2);
|
||||
}
|
@ -10,9 +10,9 @@
|
||||
* Analog sensor (potentiometer will do) attached to analog input 0
|
||||
|
||||
Created 22 April 2007
|
||||
modified 30 Aug 2011
|
||||
By David A. Mellis <dam@mellis.org>
|
||||
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
http://www.arduino.cc/en/Tutorial/Smoothing
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -61,7 +61,8 @@ void loop() {
|
||||
// calculate the average:
|
||||
average = total / numReadings;
|
||||
// send it to the computer as ASCII digits
|
||||
Serial.println(average);
|
||||
Serial.println(average);
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
created 2006
|
||||
by Nicholas Zambetti
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -19,10 +19,13 @@
|
||||
<http://www.zambetti.com>
|
||||
|
||||
*/
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
//Initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// prints title with ending line break
|
||||
Serial.println("ASCII Table ~ Character Map");
|
||||
}
|
||||
@ -33,8 +36,7 @@ int thisByte = 33;
|
||||
// for example. '!' is the same as 33, so you could also use this:
|
||||
//int thisByte = '!';
|
||||
|
||||
void loop()
|
||||
{
|
||||
void loop() {
|
||||
// prints value unaltered, i.e. the raw binary version of the
|
||||
// byte. The serial monitor interprets all bytes as
|
||||
// ASCII, so 33, the first number, will show up as '!'
|
@ -18,7 +18,7 @@
|
||||
|
||||
created 2006
|
||||
by David A. Mellis
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe and Scott Fitzgerald
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -36,7 +36,7 @@ void loop() {
|
||||
Serial.println(analogRead(A0));
|
||||
// wait a bit for the analog-to-digital converter
|
||||
// to stabilize after the last reading:
|
||||
delay(10);
|
||||
delay(2);
|
||||
}
|
||||
|
||||
/* Processing code for this example
|
@ -11,7 +11,8 @@
|
||||
* Serial monitor open on Serial port 0:
|
||||
|
||||
created 30 Dec. 2008
|
||||
by Tom Igoe
|
||||
modified 20 May 2012
|
||||
by Tom Igoe & Jed Roach
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
@ -30,4 +31,10 @@ void loop() {
|
||||
int inByte = Serial1.read();
|
||||
Serial.write(inByte);
|
||||
}
|
||||
|
||||
// read from port 0, send to port 1:
|
||||
if (Serial.available()) {
|
||||
int inByte = Serial.read();
|
||||
Serial1.write(inByte);
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
Reading a serial ASCII-encoded string.
|
||||
|
||||
This sketch demonstrates the Serial parseInt() function.
|
||||
It looks for an ASCII string of comma-separated values.
|
||||
It parses them into ints, and uses those to fade an RGB LED.
|
||||
|
||||
Circuit: Common-anode RGB LED wired like so:
|
||||
* Red cathode: digital pin 3
|
||||
* Green cathode: digital pin 5
|
||||
* blue cathode: digital pin 6
|
||||
* anode: +5V
|
||||
|
||||
created 13 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
// pins for the LEDs:
|
||||
const int redPin = 3;
|
||||
const int greenPin = 5;
|
||||
const int bluePin = 6;
|
||||
|
||||
void setup() {
|
||||
// initialize serial:
|
||||
Serial.begin(9600);
|
||||
// make the pins outputs:
|
||||
pinMode(redPin, OUTPUT);
|
||||
pinMode(greenPin, OUTPUT);
|
||||
pinMode(bluePin, OUTPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// if there's any serial available, read it:
|
||||
while (Serial.available() > 0) {
|
||||
|
||||
// look for the next valid integer in the incoming serial stream:
|
||||
int red = Serial.parseInt();
|
||||
// do it again:
|
||||
int green = Serial.parseInt();
|
||||
// do it again:
|
||||
int blue = Serial.parseInt();
|
||||
|
||||
// look for the newline. That's the end of your
|
||||
// sentence:
|
||||
if (Serial.read() == '\n') {
|
||||
// constrain the values to 0 - 255 and invert
|
||||
// if you're using a common-cathode LED, just use "constrain(color, 0, 255);"
|
||||
red = 255 - constrain(red, 0, 255);
|
||||
green = 255 - constrain(green, 0, 255);
|
||||
blue = 255 - constrain(blue, 0, 255);
|
||||
|
||||
// fade the red, green, and blue legs of the LED:
|
||||
analogWrite(redPin, red);
|
||||
analogWrite(greenPin, green);
|
||||
analogWrite(bluePin, blue);
|
||||
|
||||
// print the three numbers in one string as hexadecimal:
|
||||
Serial.print(red, HEX);
|
||||
Serial.print(green, HEX);
|
||||
Serial.println(blue, HEX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,245 @@
|
||||
/*
|
||||
Serial Call and Response
|
||||
Language: Wiring/Arduino
|
||||
|
||||
This program sends an ASCII A (byte of value 65) on startup
|
||||
and repeats that until it gets some data in.
|
||||
Then it waits for a byte in the serial port, and
|
||||
sends three sensor values whenever it gets a byte in.
|
||||
|
||||
Thanks to Greg Shakar and Scott Fitzgerald for the improvements
|
||||
|
||||
The circuit:
|
||||
* potentiometers attached to analog inputs 0 and 1
|
||||
* pushbutton attached to digital I/O 2
|
||||
|
||||
Created 26 Sept. 2005
|
||||
by Tom Igoe
|
||||
modified 24 April 2012
|
||||
by Tom Igoe and Scott Fitzgerald
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/SerialCallResponse
|
||||
|
||||
*/
|
||||
|
||||
int firstSensor = 0; // first analog sensor
|
||||
int secondSensor = 0; // second analog sensor
|
||||
int thirdSensor = 0; // digital sensor
|
||||
int inByte = 0; // incoming serial byte
|
||||
|
||||
void setup()
|
||||
{
|
||||
// start serial port at 9600 bps:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
pinMode(2, INPUT); // digital sensor is on digital pin 2
|
||||
establishContact(); // send a byte to establish contact until receiver responds
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if we get a valid byte, read analog ins:
|
||||
if (Serial.available() > 0) {
|
||||
// get incoming byte:
|
||||
inByte = Serial.read();
|
||||
// read first analog input, divide by 4 to make the range 0-255:
|
||||
firstSensor = analogRead(A0)/4;
|
||||
// delay 10ms to let the ADC recover:
|
||||
delay(10);
|
||||
// read second analog input, divide by 4 to make the range 0-255:
|
||||
secondSensor = analogRead(1)/4;
|
||||
// read switch, map it to 0 or 255L
|
||||
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
|
||||
// send sensor values:
|
||||
Serial.write(firstSensor);
|
||||
Serial.write(secondSensor);
|
||||
Serial.write(thirdSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void establishContact() {
|
||||
while (Serial.available() <= 0) {
|
||||
Serial.print('A'); // send a capital A
|
||||
delay(300);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Processing sketch to run with this example:
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
import processing.serial.*;
|
||||
|
||||
int bgcolor; // Background color
|
||||
int fgcolor; // Fill color
|
||||
Serial myPort; // The serial port
|
||||
int[] serialInArray = new int[3]; // Where we'll put what we receive
|
||||
int serialCount = 0; // A count of how many bytes we receive
|
||||
int xpos, ypos; // Starting position of the ball
|
||||
boolean firstContact = false; // Whether we've heard from the microcontroller
|
||||
|
||||
void setup() {
|
||||
size(256, 256); // Stage size
|
||||
noStroke(); // No border on the next thing drawn
|
||||
|
||||
// Set the starting position of the ball (middle of the stage)
|
||||
xpos = width/2;
|
||||
ypos = height/2;
|
||||
|
||||
// Print a list of the serial ports, for debugging purposes:
|
||||
println(Serial.list());
|
||||
|
||||
// I know that the first port in the serial list on my mac
|
||||
// is always my FTDI adaptor, so I open Serial.list()[0].
|
||||
// On Windows machines, this generally opens COM1.
|
||||
// Open whatever port is the one you're using.
|
||||
String portName = Serial.list()[0];
|
||||
myPort = new Serial(this, portName, 9600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(bgcolor);
|
||||
fill(fgcolor);
|
||||
// Draw the shape
|
||||
ellipse(xpos, ypos, 20, 20);
|
||||
}
|
||||
|
||||
void serialEvent(Serial myPort) {
|
||||
// read a byte from the serial port:
|
||||
int inByte = myPort.read();
|
||||
// if this is the first byte received, and it's an A,
|
||||
// clear the serial buffer and note that you've
|
||||
// had first contact from the microcontroller.
|
||||
// Otherwise, add the incoming byte to the array:
|
||||
if (firstContact == false) {
|
||||
if (inByte == 'A') {
|
||||
myPort.clear(); // clear the serial port buffer
|
||||
firstContact = true; // you've had first contact from the microcontroller
|
||||
myPort.write('A'); // ask for more
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Add the latest byte from the serial port to array:
|
||||
serialInArray[serialCount] = inByte;
|
||||
serialCount++;
|
||||
|
||||
// If we have 3 bytes:
|
||||
if (serialCount > 2 ) {
|
||||
xpos = serialInArray[0];
|
||||
ypos = serialInArray[1];
|
||||
fgcolor = serialInArray[2];
|
||||
|
||||
// print the values (for debugging purposes only):
|
||||
println(xpos + "\t" + ypos + "\t" + fgcolor);
|
||||
|
||||
// Send a capital A to request new sensor readings:
|
||||
myPort.write('A');
|
||||
// Reset serialCount:
|
||||
serialCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
Max/MSP version 5 patch to run with this example:
|
||||
|
||||
----------begin_max5_patcher----------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cH05ylVM0jwuidlkmAif374ih5M5QPfccr8Hqifff
|
||||
otN8pt3hUcaWu8nosBhwmD0Epw5KmoF.poxy4YHbnjqfPJqcM3Y2vun7nS.i
|
||||
f3eETiqcRX2LR.4QmhZrkoCSGwzZrqKHrVR8caari+55d2caPqmq5n.ywe8Q
|
||||
WrZL9fpwVXeaogMByE6y1SMdjk+gbavbN7fYvVtt1C2XwHJSzpk+tidUO25H
|
||||
UB9onw9mlFQ10fhpZBaDatcMTTEGcJpwzqg92qqiVtM6Cu0IRQ0ndEdfCAqV
|
||||
l0qYAUmPrctbxO4XCuPMa1asYzKDks1D52ZCne6Mednz9qW8+.vfqkDA
|
||||
-----------end_max5_patcher-----------
|
||||
|
||||
|
||||
|
||||
*/
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
Serial Call and Response in ASCII
|
||||
Language: Wiring/Arduino
|
||||
|
||||
This program sends an ASCII A (byte of value 65) on startup
|
||||
and repeats that until it gets some data in.
|
||||
Then it waits for a byte in the serial port, and
|
||||
sends three ASCII-encoded, comma-separated sensor values,
|
||||
truncated by a linefeed and carriage return,
|
||||
whenever it gets a byte in.
|
||||
|
||||
Thanks to Greg Shakar and Scott Fitzgerald for the improvements
|
||||
|
||||
The circuit:
|
||||
* potentiometers attached to analog inputs 0 and 1
|
||||
* pushbutton attached to digital I/O 2
|
||||
|
||||
|
||||
|
||||
Created 26 Sept. 2005
|
||||
by Tom Igoe
|
||||
modified 24 Apr 2012
|
||||
by Tom Igoe and Scott Fitzgerald
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII
|
||||
|
||||
*/
|
||||
|
||||
int firstSensor = 0; // first analog sensor
|
||||
int secondSensor = 0; // second analog sensor
|
||||
int thirdSensor = 0; // digital sensor
|
||||
int inByte = 0; // incoming serial byte
|
||||
|
||||
void setup()
|
||||
{
|
||||
// start serial port at 9600 bps and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
|
||||
pinMode(2, INPUT); // digital sensor is on digital pin 2
|
||||
establishContact(); // send a byte to establish contact until receiver responds
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if we get a valid byte, read analog ins:
|
||||
if (Serial.available() > 0) {
|
||||
// get incoming byte:
|
||||
inByte = Serial.read();
|
||||
// read first analog input:
|
||||
firstSensor = analogRead(A0);
|
||||
// read second analog input:
|
||||
secondSensor = analogRead(A1);
|
||||
// read switch, map it to 0 or 255L
|
||||
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
|
||||
// send sensor values:
|
||||
Serial.print(firstSensor);
|
||||
Serial.print(",");
|
||||
Serial.print(secondSensor);
|
||||
Serial.print(",");
|
||||
Serial.println(thirdSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void establishContact() {
|
||||
while (Serial.available() <= 0) {
|
||||
Serial.println("0,0,0"); // send an initial string
|
||||
delay(300);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Processing code to run with this example:
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
import processing.serial.*; // import the Processing serial library
|
||||
Serial myPort; // The serial port
|
||||
|
||||
float bgcolor; // Background color
|
||||
float fgcolor; // Fill color
|
||||
float xpos, ypos; // Starting position of the ball
|
||||
|
||||
void setup() {
|
||||
size(640,480);
|
||||
|
||||
// List all the available serial ports
|
||||
println(Serial.list());
|
||||
|
||||
// I know that the first port in the serial list on my mac
|
||||
// is always my Arduino module, so I open Serial.list()[0].
|
||||
// Change the 0 to the appropriate number of the serial port
|
||||
// that your microcontroller is attached to.
|
||||
myPort = new Serial(this, Serial.list()[0], 9600);
|
||||
|
||||
// read bytes into a buffer until you get a linefeed (ASCII 10):
|
||||
myPort.bufferUntil('\n');
|
||||
|
||||
// draw with smooth edges:
|
||||
smooth();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(bgcolor);
|
||||
fill(fgcolor);
|
||||
// Draw the shape
|
||||
ellipse(xpos, ypos, 20, 20);
|
||||
}
|
||||
|
||||
// serialEvent method is run automatically by the Processing applet
|
||||
// whenever the buffer reaches the byte value set in the bufferUntil()
|
||||
// method in the setup():
|
||||
|
||||
void serialEvent(Serial myPort) {
|
||||
// read the serial buffer:
|
||||
String myString = myPort.readStringUntil('\n');
|
||||
// if you got any bytes other than the linefeed:
|
||||
myString = trim(myString);
|
||||
|
||||
// split the string at the commas
|
||||
// and convert the sections into integers:
|
||||
int sensors[] = int(split(myString, ','));
|
||||
|
||||
// print out the values you got:
|
||||
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
|
||||
print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
|
||||
}
|
||||
// add a linefeed after all the sensor values are printed:
|
||||
println();
|
||||
if (sensors.length > 1) {
|
||||
xpos = map(sensors[0], 0,1023,0,width);
|
||||
ypos = map(sensors[1], 0,1023,0,height);
|
||||
fgcolor = sensors[2];
|
||||
}
|
||||
// send a byte to ask for more data:
|
||||
myPort.write("A");
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Max/MSP version 5 patch to run with this example:
|
||||
----------begin_max5_patcher----------
|
||||
3640.3oc6cs0jZajE94Y9UzKkeHoVloTeSHkm1II0VkeHIthSs6C1obIjZ.E
|
||||
KjHRhY7jT4+9d5KBj.jTCAXfoV6x.sj5VmyWet127ed6MCFm8EQw.z2f9.5l
|
||||
a9yau4F0kjW3FS4aFLO3KgIAEpGaPX174hzxAC02qT7kR80mkkUHPAnBQdbP
|
||||
BZQVdIZRd1bT4r3BDTmkU0YQPY3r3zoeJWDVpe2ttr6cFhvXt7KhyH8W26f9
|
||||
USkhiTulrw+1czQUszjrzxzf4B0sdP9dqtS5x4woIhREQiWewrkkUW0oViTD
|
||||
+GpFASt2Qd0+51akeLzRPIU7DPXagIFnH.4653f9WAKKyxVHRQNcfDXlih2w
|
||||
puvbdWHAlcTPBRKHg4x5mr74E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gQOmud
|
||||
KZic4QKzCw+7ROm8nY2LfMsEDtdfeMKSn5Ev95IQhorcqJcBrzPsQUhRNe8M
|
||||
1X6lhOezC4Bidv1nKcFs8YimJ9n8RWZXiO7aSCxDRLdjd91qU5TnmXCeRvmR
|
||||
9jnm7b15RmJ9rO4Kr+IgO04BfczyOpqx9npzofOsIlaR8Mo0IUMR48i0mYly
|
||||
lVMwlw6gbloGRezy4yKEw6BHBBWik.eRi3DNM5KDahS.SOE1EjmXl7Uyqo9T
|
||||
AtQAO8fG3oLX3cZFxKh0FLNSRfDaoG74gdvW.ZDU9FMGSdFMBt+IQh.6eIvw
|
||||
FujTkJREGKKcJ3X2WtXf7Ub1HywEqxh2tJnE.FcZhMByrcXQw1x+bOWJYjpy
|
||||
lv8oq55aEHLcwD8hJjxbVU5EigcNtL7Ql76KVVp69Huhcb87vpoCkRYT+96v
|
||||
Hd5Ay1rofMqm+FkLYvv0+GL3FkL6bLp21kL6QFNV8BNM48foWBV4zt1wXm5V
|
||||
4jkNEbL45dtNw13Iltmi9sAyY0S0l8BR+3yWjVXax7eOmKrp4m0QKIal6VYo
|
||||
SAf5XQxSrCa5l0qk45k5kAzqEgMNgzkz9FmL5abpnu4IhNzZ+0s+OKCSg0.
|
||||
-----------end_max5_patcher-----------
|
||||
|
||||
*/
|
@ -16,7 +16,7 @@
|
||||
connected to pin 13, so you don't need any extra components for this example.
|
||||
|
||||
created 17 Jan 2009
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -51,6 +51,6 @@ void loop() {
|
||||
|
||||
// print the analog value:
|
||||
Serial.println(analogValue);
|
||||
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* 10K resistor from analog in 0 to ground
|
||||
|
||||
created 1 Jul 2009
|
||||
modified 30 Aug 2011
|
||||
modified 9 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
@ -22,7 +22,8 @@
|
||||
http://www.arduino.cc/en/Tutorial/SwitchCase
|
||||
*/
|
||||
|
||||
// these constants won't change:
|
||||
// these constants won't change. They are the
|
||||
// lowest and highest readings you get from your sensor:
|
||||
const int sensorMin = 0; // sensor minimum, discovered through experiment
|
||||
const int sensorMax = 600; // sensor maximum, discovered through experiment
|
||||
|
||||
@ -53,7 +54,7 @@ void loop() {
|
||||
Serial.println("bright");
|
||||
break;
|
||||
}
|
||||
|
||||
delay(1); // delay in between reads for stability
|
||||
}
|
||||
|
||||
|
@ -50,9 +50,7 @@ int x = 5;
|
||||
int y = 5;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
// initialize the I/O pins as outputs:
|
||||
|
||||
// initialize the I/O pins as outputs
|
||||
// iterate over the pins:
|
||||
for (int thisPin = 0; thisPin < 8; thisPin++) {
|
||||
// initialize the output pins:
|
Binary file not shown.
@ -5,14 +5,18 @@
|
||||
Send any byte and the sketch will tell you about it.
|
||||
|
||||
created 29 Nov 2010
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications:
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("send any byte and I'll tell you everything I can about it");
|
||||
@ -77,9 +81,3 @@ void loop() {
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
You can also add several different data types to string, as shown here:
|
||||
|
||||
created 27 July 2010
|
||||
modified 30 Aug 2011
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringAdditionOperator
|
||||
@ -17,11 +17,18 @@
|
||||
String stringOne, stringTwo, stringThree;
|
||||
|
||||
void setup() {
|
||||
// initialize serial and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
stringOne = String("stringThree = ");
|
||||
stringTwo = String("this string");
|
||||
stringThree = String ();
|
||||
// send an intro:
|
||||
Serial.println("\n\nAdding strings together (concatenation):");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@ -58,4 +65,4 @@ void loop() {
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
Examples of how to append different data types to strings
|
||||
|
||||
created 27 July 2010
|
||||
modified 30 Aug 2011
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringAppendOperator
|
||||
@ -14,10 +14,17 @@
|
||||
String stringOne, stringTwo;
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
stringOne = String("Sensor ");
|
||||
stringTwo = String("value");
|
||||
// send an intro:
|
||||
Serial.println("\n\nAppending to a string:");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@ -61,4 +68,5 @@ void loop() {
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
Examples of how to change the case of a string
|
||||
|
||||
created 27 July 2010
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringCaseChanges
|
||||
@ -12,24 +13,31 @@
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString case changes:");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// toUpperCase() changes all letters to upper case:
|
||||
String stringOne = "<html><head><body>";
|
||||
Serial.println(stringOne);
|
||||
stringOne = (stringOne.toUpperCase());
|
||||
stringOne.toUpperCase();
|
||||
Serial.println(stringOne);
|
||||
|
||||
// toLowerCase() changes all letters to lower case:
|
||||
|
||||
// toLowerCase() changes all letters to lower case:
|
||||
String stringTwo = "</BODY></HTML>";
|
||||
Serial.println(stringTwo);
|
||||
stringTwo = stringTwo.toLowerCase();
|
||||
stringTwo.toLowerCase();
|
||||
Serial.println(stringTwo);
|
||||
|
||||
|
||||
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
Examples of how to get and set characters of a String
|
||||
|
||||
created 27 July 2010
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringCharacters
|
||||
@ -12,7 +13,12 @@
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
Serial.println("\n\nString charAt() and setCharAt():");
|
||||
}
|
||||
|
||||
@ -20,18 +26,19 @@ void loop() {
|
||||
// make a string to report a sensor reading:
|
||||
String reportString = "SensorReading: 456";
|
||||
Serial.println(reportString);
|
||||
|
||||
|
||||
// the reading's most significant digit is at position 15 in the reportString:
|
||||
String mostSignificantDigit = reportString.charAt(15);
|
||||
char mostSignificantDigit = reportString.charAt(15);
|
||||
Serial.println("Most significant digit of the sensor reading is: " + mostSignificantDigit);
|
||||
|
||||
// add blank space:
|
||||
// add blank space:
|
||||
Serial.println();
|
||||
|
||||
|
||||
// you can alo set the character of a string. Change the : to a = character
|
||||
reportString.setCharAt(13, '=');
|
||||
Serial.println(reportString);
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
||||
}
|
||||
|
@ -4,21 +4,29 @@
|
||||
Examples of how to compare strings using the comparison operators
|
||||
|
||||
created 27 July 2010
|
||||
modified 30 Aug 2011
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringComparisonOperators
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
|
||||
String stringOne, stringTwo;
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
|
||||
stringOne = String("this");
|
||||
stringTwo = String("that");
|
||||
// send an intro:
|
||||
Serial.println("\n\nComparing Strings:");
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
|
||||
@ -57,7 +65,7 @@ void loop() {
|
||||
// a numeric string compared to the number it represents:
|
||||
stringOne = "1";
|
||||
int numberOne = 1;
|
||||
if (stringOne == numberOne) {
|
||||
if (stringOne.toInt() == numberOne) {
|
||||
Serial.println(stringOne + " = " + numberOne);
|
||||
}
|
||||
|
||||
@ -121,4 +129,4 @@ void loop() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
String constructors
|
||||
|
||||
Examples of how to create strings from other data types
|
||||
|
||||
created 27 July 2010
|
||||
modified 30 Aug 2011
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringConstructors
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString Constructors:");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// using a constant String:
|
||||
String stringOne = "Hello String";
|
||||
Serial.println(stringOne); // prints "Hello String"
|
||||
|
||||
// converting a constant char into a String:
|
||||
stringOne = String('a');
|
||||
Serial.println(stringOne); // prints "a"
|
||||
|
||||
// converting a constant string into a String object:
|
||||
String stringTwo = String("This is a string");
|
||||
Serial.println(stringTwo); // prints "This is a string"
|
||||
|
||||
// concatenating two strings:
|
||||
stringOne = String(stringTwo + " with more");
|
||||
// prints "This is a string with more":
|
||||
Serial.println(stringOne);
|
||||
|
||||
// using a constant integer:
|
||||
stringOne = String(13);
|
||||
Serial.println(stringOne); // prints "13"
|
||||
|
||||
// using an int and a base:
|
||||
stringOne = String(analogRead(A0), DEC);
|
||||
// prints "453" or whatever the value of analogRead(A0) is
|
||||
Serial.println(stringOne);
|
||||
|
||||
// using an int and a base (hexadecimal):
|
||||
stringOne = String(45, HEX);
|
||||
// prints "2d", which is the hexadecimal version of decimal 45:
|
||||
Serial.println(stringOne);
|
||||
|
||||
// using an int and a base (binary)
|
||||
stringOne = String(255, BIN);
|
||||
// prints "11111111" which is the binary value of 255
|
||||
Serial.println(stringOne);
|
||||
|
||||
// using a long and a base:
|
||||
stringOne = String(millis(), DEC);
|
||||
// prints "123456" or whatever the value of millis() is:
|
||||
Serial.println(stringOne);
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
Examples of how to evaluate, look for, and replace characters in a String
|
||||
|
||||
created 27 July 2010
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringIndexOf
|
||||
@ -12,13 +13,19 @@
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
Serial.println("\n\nString indexOf() and lastIndexOf() functions:");
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString indexOf() and lastIndexOf() functions:");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// indexOf() returns the position (i.e. index) of a particular character
|
||||
// indexOf() returns the position (i.e. index) of a particular character
|
||||
// in a string. For example, if you were parsing HTML tags, you could use it:
|
||||
String stringOne = "<HTML><HEAD><BODY>";
|
||||
int firstClosingBracket = stringOne.indexOf('>');
|
||||
@ -47,12 +54,13 @@ void loop() {
|
||||
Serial.println("The index of the last list item in the string " + stringOne + " is " + lastListItem);
|
||||
|
||||
|
||||
// lastIndexOf() can also search for a string:
|
||||
stringOne = "<p>Lorem ipsum dolor sit amet</p><p>Ipsem</p><p>Quod</p>";
|
||||
// lastIndexOf() can also search for a string:
|
||||
stringOne = "<p>Lorem ipsum dolor sit amet</p><p>Ipsem</p><p>Quod</p>";
|
||||
int lastParagraph = stringOne.lastIndexOf("<p");
|
||||
int secondLastGraf = stringOne.lastIndexOf("<p", lastParagraph - 1);
|
||||
Serial.println("The index of the second last paragraph tag " + stringOne + " is " + secondLastGraf);
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
||||
|
@ -15,8 +15,15 @@ String txtMsg = ""; // a string for incoming text
|
||||
int lastStringLength = txtMsg.length(); // previous length of the String
|
||||
|
||||
void setup() {
|
||||
// open the serial port:
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString length():");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@ -40,4 +47,4 @@ void loop() {
|
||||
// note the length for next time through the loop:
|
||||
lastStringLength = txtMsg.length();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
Examples of how to use length() and trim() in a String
|
||||
|
||||
created 27 July 2010
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringLengthTrim
|
||||
@ -12,8 +13,15 @@
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString length() and trim():");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@ -24,7 +32,7 @@ void loop() {
|
||||
Serial.println(stringOne.length());
|
||||
|
||||
// trim the white space off the string:
|
||||
stringOne = stringOne.trim();
|
||||
stringOne.trim();
|
||||
Serial.print(stringOne);
|
||||
Serial.print("<--- end of trimmed string. Length: ");
|
||||
Serial.println(stringOne.length());
|
BIN
build/shared/examples/08.Strings/StringReplace/.swp
Normal file
BIN
build/shared/examples/08.Strings/StringReplace/.swp
Normal file
Binary file not shown.
@ -0,0 +1,50 @@
|
||||
/*
|
||||
String replace()
|
||||
|
||||
Examples of how to replace characters or substrings of a string
|
||||
|
||||
created 27 July 2010
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringReplace
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString replace:\n");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
String stringOne = "<html><head><body>";
|
||||
Serial.println(stringOne);
|
||||
// replace() changes all instances of one substring with another:
|
||||
// first, make a copy of th original string:
|
||||
String stringTwo = stringOne;
|
||||
// then perform the replacements:
|
||||
stringTwo.replace("<", "</");
|
||||
// print the original:
|
||||
Serial.println("Original string: " + stringOne);
|
||||
// and print the modified string:
|
||||
Serial.println("Modified string: " + stringTwo);
|
||||
|
||||
// you can also use replace() on single characters:
|
||||
String normalString = "bookkeeper";
|
||||
Serial.println("normal: " + normalString);
|
||||
String leetString = normalString;
|
||||
leetString.replace('o', '0');
|
||||
leetString.replace('e', '3');
|
||||
Serial.println("l33tspeak: " + leetString);
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
Examples of how to use startsWith() and endsWith() in a String
|
||||
|
||||
created 27 July 2010
|
||||
modified 30 Aug 2011
|
||||
modified 2 Apr 2012
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringStartsWithEndsWith
|
||||
@ -13,25 +13,31 @@
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
Serial.println("\n\nString startsWith() and endsWith():");
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString startsWith() and endsWith():");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// startsWith() checks to see if a String starts with a particular substring:
|
||||
String stringOne = "HTTP/1.1 200 OK";
|
||||
Serial.println(stringOne);
|
||||
// startsWith() checks to see if a String starts with a particular substring:
|
||||
String stringOne = "HTTP/1.1 200 OK";
|
||||
Serial.println(stringOne);
|
||||
if (stringOne.startsWith("HTTP/1.1")) {
|
||||
Serial.println("Server's using http version 1.1");
|
||||
}
|
||||
|
||||
|
||||
// you can also look for startsWith() at an offset position in the string:
|
||||
stringOne = "HTTP/1.1 200 OK";
|
||||
stringOne = "HTTP/1.1 200 OK";
|
||||
if (stringOne.startsWith("200 OK", 9)) {
|
||||
Serial.println("Got an OK from the server");
|
||||
}
|
||||
|
||||
|
||||
// endsWith() checks to see if a String ends with a particular character:
|
||||
String sensorReading = "sensor = ";
|
||||
sensorReading += analogRead(A0);
|
||||
@ -44,6 +50,6 @@ void loop() {
|
||||
|
||||
}
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
@ -3,8 +3,9 @@
|
||||
|
||||
Examples of how to use substring in a String
|
||||
|
||||
created 27 July 2010
|
||||
by Tom Igoe
|
||||
created 27 July 2010,
|
||||
modified 2 Apr 2012
|
||||
by Zach Eveland
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringSubstring
|
||||
|
||||
@ -12,15 +13,22 @@
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString substring():");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Set up a String:
|
||||
String stringOne = "Content-Type: text/html";
|
||||
Serial.println(stringOne);
|
||||
|
||||
|
||||
// substring(index) looks for the substring from the index position to the end:
|
||||
if (stringOne.substring(19) == "html") {
|
||||
Serial.println("It's an html file");
|
||||
@ -32,4 +40,4 @@ void loop() {
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
||||
}
|
@ -16,8 +16,15 @@
|
||||
String inString = ""; // string to hold input
|
||||
|
||||
void setup() {
|
||||
// Initialize serial communications:
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString toInt():");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@ -42,6 +49,3 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,235 @@
|
||||
/*
|
||||
Serial RGB controller
|
||||
|
||||
Reads a serial input string looking for three comma-separated
|
||||
integers with a newline at the end. Values should be between
|
||||
0 and 255. The sketch uses those values to set the color
|
||||
of an RGB LED attached to pins 9 - 11.
|
||||
|
||||
The circuit:
|
||||
* Common-anode RGB LED cathodes attached to pins 9 - 11
|
||||
* LED anode connected to pin 13
|
||||
|
||||
To turn on any given channel, set the pin LOW.
|
||||
To turn off, set the pin HIGH. The higher the analogWrite level,
|
||||
the lower the brightness.
|
||||
|
||||
created 29 Nov 2010
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
String inString = ""; // string to hold input
|
||||
int currentColor = 0;
|
||||
int red, green, blue = 0;
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
// send an intro:
|
||||
Serial.println("\n\nString toInt() RGB:");
|
||||
Serial.println();
|
||||
// set LED cathode pins as outputs:
|
||||
pinMode(9, OUTPUT);
|
||||
pinMode(10, OUTPUT);
|
||||
pinMode(11, OUTPUT);
|
||||
// turn on pin 13 to power the LEDs:
|
||||
pinMode(13, OUTPUT);
|
||||
digitalWrite(13, HIGH);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int inChar;
|
||||
|
||||
// Read serial input:
|
||||
if (Serial.available() > 0) {
|
||||
inChar = Serial.read();
|
||||
}
|
||||
|
||||
if (isDigit(inChar)) {
|
||||
// convert the incoming byte to a char
|
||||
// and add it to the string:
|
||||
inString += (char)inChar;
|
||||
}
|
||||
|
||||
// if you get a comma, convert to a number,
|
||||
// set the appropriate color, and increment
|
||||
// the color counter:
|
||||
if (inChar == ',') {
|
||||
// do something different for each value of currentColor:
|
||||
switch (currentColor) {
|
||||
case 0: // 0 = red
|
||||
red = inString.toInt();
|
||||
// clear the string for new input:
|
||||
inString = "";
|
||||
break;
|
||||
case 1: // 1 = green:
|
||||
green = inString.toInt();
|
||||
// clear the string for new input:
|
||||
inString = "";
|
||||
break;
|
||||
}
|
||||
currentColor++;
|
||||
}
|
||||
// if you get a newline, you know you've got
|
||||
// the last color, i.e. blue:
|
||||
if (inChar == '\n') {
|
||||
blue = inString.toInt();
|
||||
|
||||
// set the levels of the LED.
|
||||
// subtract value from 255 because a higher
|
||||
// analogWrite level means a dimmer LED, since
|
||||
// you're raising the level on the anode:
|
||||
analogWrite(11, 255 - red);
|
||||
analogWrite(9, 255 - green);
|
||||
analogWrite(10, 255 - blue);
|
||||
|
||||
// print the colors:
|
||||
Serial.print("Red: ");
|
||||
Serial.print(red);
|
||||
Serial.print(", Green: ");
|
||||
Serial.print(green);
|
||||
Serial.print(", Blue: ");
|
||||
Serial.println(blue);
|
||||
|
||||
// clear the string for new input:
|
||||
inString = "";
|
||||
// reset the color counter:
|
||||
currentColor = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Here's a Processing sketch that will draw a color wheel and send a serial
|
||||
string with the color you click on:
|
||||
|
||||
// Subtractive Color Wheel with Serial
|
||||
// Based on a Processing example by Ira Greenberg.
|
||||
// Serial output added by Tom Igoe
|
||||
//
|
||||
// The primaries are red, yellow, and blue. The secondaries are green,
|
||||
// purple, and orange. The tertiaries are yellow-orange, red-orange,
|
||||
// red-purple, blue-purple, blue-green, and yellow-green.
|
||||
//
|
||||
// Create a shade or tint of the subtractive color wheel using
|
||||
// SHADE or TINT parameters.
|
||||
|
||||
// Updated 29 November 2010.
|
||||
|
||||
|
||||
|
||||
import processing.serial.*;
|
||||
|
||||
int segs = 12;
|
||||
int steps = 6;
|
||||
float rotAdjust = TWO_PI / segs / 2;
|
||||
float radius;
|
||||
float segWidth;
|
||||
float interval = TWO_PI / segs;
|
||||
|
||||
Serial myPort;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
background(127);
|
||||
smooth();
|
||||
ellipseMode(RADIUS);
|
||||
noStroke();
|
||||
// make the diameter 90% of the sketch area
|
||||
radius = min(width, height) * 0.45;
|
||||
segWidth = radius / steps;
|
||||
|
||||
// swap which line is commented out to draw the other version
|
||||
// drawTintWheel();
|
||||
drawShadeWheel();
|
||||
// open the first serial port in your computer's list
|
||||
myPort = new Serial(this, Serial.list()[0], 9600);
|
||||
}
|
||||
|
||||
|
||||
void drawShadeWheel() {
|
||||
for (int j = 0; j < steps; j++) {
|
||||
color[] cols = {
|
||||
color(255-(255/steps)*j, 255-(255/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/1.5)-((255/1.5)/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/2)-((255/2)/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j, 0),
|
||||
color(255-(255/steps)*j, 0, 0),
|
||||
color(255-(255/steps)*j, 0, (255/2)-((255/2)/steps)*j),
|
||||
color(255-(255/steps)*j, 0, 255-(255/steps)*j),
|
||||
color((255/2)-((255/2)/steps)*j, 0, 255-(255/steps)*j),
|
||||
color(0, 0, 255-(255/steps)*j),
|
||||
color(0, 255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j),
|
||||
color(0, 255-(255/steps)*j, 0),
|
||||
color((255/2)-((255/2)/steps)*j, 255-(255/steps)*j, 0)
|
||||
};
|
||||
for (int i = 0; i < segs; i++) {
|
||||
fill(cols[i]);
|
||||
arc(width/2, height/2, radius, radius,
|
||||
interval*i+rotAdjust, interval*(i+1)+rotAdjust);
|
||||
}
|
||||
radius -= segWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void drawTintWheel() {
|
||||
for (int j = 0; j < steps; j++) {
|
||||
color[] cols = {
|
||||
color((255/steps)*j, (255/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/1.5)/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/2)/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/2.5)/steps)*j, 0),
|
||||
color((255/steps)*j, 0, 0),
|
||||
color((255/steps)*j, 0, ((255/2)/steps)*j),
|
||||
color((255/steps)*j, 0, (255/steps)*j),
|
||||
color(((255/2)/steps)*j, 0, (255/steps)*j),
|
||||
color(0, 0, (255/steps)*j),
|
||||
color(0, (255/steps)*j, ((255/2.5)/steps)*j),
|
||||
color(0, (255/steps)*j, 0),
|
||||
color(((255/2)/steps)*j, (255/steps)*j, 0)
|
||||
};
|
||||
for (int i = 0; i < segs; i++) {
|
||||
fill(cols[i]);
|
||||
arc(width/2, height/2, radius, radius,
|
||||
interval*i+rotAdjust, interval*(i+1)+rotAdjust);
|
||||
}
|
||||
radius -= segWidth;
|
||||
}
|
||||
}
|
||||
|
||||
void draw() {
|
||||
// nothing happens here
|
||||
}
|
||||
|
||||
void mouseReleased() {
|
||||
// get the color of the mouse position's pixel:
|
||||
color targetColor = get(mouseX, mouseY);
|
||||
// get the component values:
|
||||
int r = int(red(targetColor));
|
||||
int g = int(green(targetColor));
|
||||
int b = int(blue(targetColor));
|
||||
// make a comma-separated string:
|
||||
String colorString = r + "," + g + "," + b + "\n";
|
||||
// send it out the serial port:
|
||||
myPort.write(colorString );
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
/*
|
||||
AnalogReadSerial
|
||||
Reads an analog input on pin 0, prints the result to the serial monitor
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int sensorValue = analogRead(A0);
|
||||
Serial.println(sensorValue);
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
Blink
|
||||
Turns on an LED on for one second, then off for one second, repeatedly.
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
// initialize the digital pin as an output.
|
||||
// Pin 13 has an LED connected on most Arduino boards:
|
||||
pinMode(13, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
digitalWrite(13, HIGH); // set the LED on
|
||||
delay(1000); // wait for a second
|
||||
digitalWrite(13, LOW); // set the LED off
|
||||
delay(1000); // wait for a second
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
DigitalReadSerial
|
||||
Reads a digital input on pin 2, prints the result to the serial monitor
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
pinMode(2, INPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int sensorValue = digitalRead(2);
|
||||
Serial.println(sensorValue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,211 +0,0 @@
|
||||
/*
|
||||
Serial Call and Response
|
||||
Language: Wiring/Arduino
|
||||
|
||||
This program sends an ASCII A (byte of value 65) on startup
|
||||
and repeats that until it gets some data in.
|
||||
Then it waits for a byte in the serial port, and
|
||||
sends three sensor values whenever it gets a byte in.
|
||||
|
||||
Thanks to Greg Shakar and Scott Fitzgerald for the improvements
|
||||
|
||||
The circuit:
|
||||
* potentiometers attached to analog inputs 0 and 1
|
||||
* pushbutton attached to digital I/O 2
|
||||
|
||||
Created 26 Sept. 2005
|
||||
by Tom Igoe
|
||||
modified 30 Aug 2011
|
||||
by Tom Igoe and Scott Fitzgerald
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/SerialCallResponse
|
||||
|
||||
*/
|
||||
|
||||
int firstSensor = 0; // first analog sensor
|
||||
int secondSensor = 0; // second analog sensor
|
||||
int thirdSensor = 0; // digital sensor
|
||||
int inByte = 0; // incoming serial byte
|
||||
|
||||
void setup()
|
||||
{
|
||||
// start serial port at 9600 bps:
|
||||
Serial.begin(9600);
|
||||
pinMode(2, INPUT); // digital sensor is on digital pin 2
|
||||
establishContact(); // send a byte to establish contact until receiver responds
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if we get a valid byte, read analog ins:
|
||||
if (Serial.available() > 0) {
|
||||
// get incoming byte:
|
||||
inByte = Serial.read();
|
||||
// read first analog input, divide by 4 to make the range 0-255:
|
||||
firstSensor = analogRead(A0)/4;
|
||||
// delay 10ms to let the ADC recover:
|
||||
delay(10);
|
||||
// read second analog input, divide by 4 to make the range 0-255:
|
||||
secondSensor = analogRead(1)/4;
|
||||
// read switch, map it to 0 or 255L
|
||||
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
|
||||
// send sensor values:
|
||||
Serial.write(firstSensor);
|
||||
Serial.write(secondSensor);
|
||||
Serial.write(thirdSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void establishContact() {
|
||||
while (Serial.available() <= 0) {
|
||||
Serial.print('A'); // send a capital A
|
||||
delay(300);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Processing sketch to run with this example:
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
import processing.serial.*;
|
||||
|
||||
int bgcolor; // Background color
|
||||
int fgcolor; // Fill color
|
||||
Serial myPort; // The serial port
|
||||
int[] serialInArray = new int[3]; // Where we'll put what we receive
|
||||
int serialCount = 0; // A count of how many bytes we receive
|
||||
int xpos, ypos; // Starting position of the ball
|
||||
boolean firstContact = false; // Whether we've heard from the microcontroller
|
||||
|
||||
void setup() {
|
||||
size(256, 256); // Stage size
|
||||
noStroke(); // No border on the next thing drawn
|
||||
|
||||
// Set the starting position of the ball (middle of the stage)
|
||||
xpos = width/2;
|
||||
ypos = height/2;
|
||||
|
||||
// Print a list of the serial ports, for debugging purposes:
|
||||
println(Serial.list());
|
||||
|
||||
// I know that the first port in the serial list on my mac
|
||||
// is always my FTDI adaptor, so I open Serial.list()[0].
|
||||
// On Windows machines, this generally opens COM1.
|
||||
// Open whatever port is the one you're using.
|
||||
String portName = Serial.list()[0];
|
||||
myPort = new Serial(this, portName, 9600);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(bgcolor);
|
||||
fill(fgcolor);
|
||||
// Draw the shape
|
||||
ellipse(xpos, ypos, 20, 20);
|
||||
}
|
||||
|
||||
void serialEvent(Serial myPort) {
|
||||
// read a byte from the serial port:
|
||||
int inByte = myPort.read();
|
||||
// if this is the first byte received, and it's an A,
|
||||
// clear the serial buffer and note that you've
|
||||
// had first contact from the microcontroller.
|
||||
// Otherwise, add the incoming byte to the array:
|
||||
if (firstContact == false) {
|
||||
if (inByte == 'A') {
|
||||
myPort.clear(); // clear the serial port buffer
|
||||
firstContact = true; // you've had first contact from the microcontroller
|
||||
myPort.write('A'); // ask for more
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Add the latest byte from the serial port to array:
|
||||
serialInArray[serialCount] = inByte;
|
||||
serialCount++;
|
||||
|
||||
// If we have 3 bytes:
|
||||
if (serialCount > 2 ) {
|
||||
xpos = serialInArray[0];
|
||||
ypos = serialInArray[1];
|
||||
fgcolor = serialInArray[2];
|
||||
|
||||
// print the values (for debugging purposes only):
|
||||
println(xpos + "\t" + ypos + "\t" + fgcolor);
|
||||
|
||||
// Send a capital A to request new sensor readings:
|
||||
myPort.write('A');
|
||||
// Reset serialCount:
|
||||
serialCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
Max/MSP version 5 patch to run with this example:
|
||||
|
||||
----------begin_max5_patcher----------
|
||||
2569.3oc2as0jiZqD9YO+Jzw09PRc75BIAX671TaUop8gy4gLoNmG1YqsjAY
|
||||
rxhAGPLW1T4+dZIAd.aCFeiEuYqXFABQqu9qa0Rp0ec2fgyiegmND8KnOgFL
|
||||
3utav.8sT2XPd4ACWwdwKjkpq1vU7zTV.e3Hyyj7Wj5665Tbq3LYHWJecM2z
|
||||
tCGh9b9iVyjdKEQAeIg6IMOkRmM1ZDx10UcgRF6LBgmN1Zy6H70se77+38yJ
|
||||
9DKhijQrU5Ovv6SDrvhmDksRDAedsvRJU8Tw2zUGSfuyl5ZjUckwpa922cm5
|
||||
mQsDLh3OCx0NXQJODgqENlyhBFNpkvBchFVzfCwZ+vh60DVHm.r3EuZEORtC
|
||||
t7.WISnOvBCe+uwSWG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v4KbOAuozkHpxCQzvc7LLZiSBR25jffuBy5IWORw5KE
|
||||
CagO+YWiuFKOA0VOzDY5zRRqtz4Jszqgz5ZjVWqxRqpTWXei6VWyXx0d4nfB
|
||||
+8c+C81VE7B
|
||||
-----------end_max5_patcher-----------
|
||||
|
||||
|
||||
*/
|
@ -1,224 +0,0 @@
|
||||
/*
|
||||
Serial Call and Response in ASCII
|
||||
Language: Wiring/Arduino
|
||||
|
||||
This program sends an ASCII A (byte of value 65) on startup
|
||||
and repeats that until it gets some data in.
|
||||
Then it waits for a byte in the serial port, and
|
||||
sends three ASCII-encoded, comma-separated sensor values,
|
||||
truncated by a linefeed and carriage return,
|
||||
whenever it gets a byte in.
|
||||
|
||||
Thanks to Greg Shakar and Scott Fitzgerald for the improvements
|
||||
|
||||
The circuit:
|
||||
* potentiometers attached to analog inputs 0 and 1
|
||||
* pushbutton attached to digital I/O 2
|
||||
|
||||
|
||||
|
||||
Created 26 Sept. 2005
|
||||
by Tom Igoe
|
||||
modified 26 Oct 2011
|
||||
by Tom Igoe and Scott Fitzgerald
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/SerialCallResponseASCII
|
||||
|
||||
*/
|
||||
|
||||
int firstSensor = 0; // first analog sensor
|
||||
int secondSensor = 0; // second analog sensor
|
||||
int thirdSensor = 0; // digital sensor
|
||||
int inByte = 0; // incoming serial byte
|
||||
|
||||
void setup()
|
||||
{
|
||||
// start serial port at 9600 bps:
|
||||
Serial.begin(9600);
|
||||
pinMode(2, INPUT); // digital sensor is on digital pin 2
|
||||
establishContact(); // send a byte to establish contact until receiver responds
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// if we get a valid byte, read analog ins:
|
||||
if (Serial.available() > 0) {
|
||||
// get incoming byte:
|
||||
inByte = Serial.read();
|
||||
// read first analog input:
|
||||
firstSensor = analogRead(A0);
|
||||
// read second analog input:
|
||||
secondSensor = analogRead(A1);
|
||||
// read switch, map it to 0 or 255L
|
||||
thirdSensor = map(digitalRead(2), 0, 1, 0, 255);
|
||||
// send sensor values:
|
||||
Serial.print(firstSensor);
|
||||
Serial.print(",");
|
||||
Serial.print(secondSensor);
|
||||
Serial.print(",");
|
||||
Serial.println(thirdSensor);
|
||||
}
|
||||
}
|
||||
|
||||
void establishContact() {
|
||||
while (Serial.available() <= 0) {
|
||||
Serial.println("0,0,0"); // send an initial string
|
||||
delay(300);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Processing code to run with this example:
|
||||
|
||||
// This example code is in the public domain.
|
||||
|
||||
import processing.serial.*; // import the Processing serial library
|
||||
Serial myPort; // The serial port
|
||||
|
||||
float bgcolor; // Background color
|
||||
float fgcolor; // Fill color
|
||||
float xpos, ypos; // Starting position of the ball
|
||||
|
||||
void setup() {
|
||||
size(640,480);
|
||||
|
||||
// List all the available serial ports
|
||||
println(Serial.list());
|
||||
|
||||
// I know that the first port in the serial list on my mac
|
||||
// is always my Arduino module, so I open Serial.list()[0].
|
||||
// Change the 0 to the appropriate number of the serial port
|
||||
// that your microcontroller is attached to.
|
||||
myPort = new Serial(this, Serial.list()[0], 9600);
|
||||
|
||||
// read bytes into a buffer until you get a linefeed (ASCII 10):
|
||||
myPort.bufferUntil('\n');
|
||||
|
||||
// draw with smooth edges:
|
||||
smooth();
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(bgcolor);
|
||||
fill(fgcolor);
|
||||
// Draw the shape
|
||||
ellipse(xpos, ypos, 20, 20);
|
||||
}
|
||||
|
||||
// serialEvent method is run automatically by the Processing applet
|
||||
// whenever the buffer reaches the byte value set in the bufferUntil()
|
||||
// method in the setup():
|
||||
|
||||
void serialEvent(Serial myPort) {
|
||||
// read the serial buffer:
|
||||
String myString = myPort.readStringUntil('\n');
|
||||
// if you got any bytes other than the linefeed:
|
||||
myString = trim(myString);
|
||||
|
||||
// split the string at the commas
|
||||
// and convert the sections into integers:
|
||||
int sensors[] = int(split(myString, ','));
|
||||
|
||||
// print out the values you got:
|
||||
for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
|
||||
print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
|
||||
}
|
||||
// add a linefeed after all the sensor values are printed:
|
||||
println();
|
||||
if (sensors.length > 1) {
|
||||
xpos = map(sensors[0], 0,1023,0,width);
|
||||
ypos = map(sensors[1], 0,1023,0,height);
|
||||
fgcolor = sensors[2];
|
||||
}
|
||||
// send a byte to ask for more data:
|
||||
myPort.write("A");
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Max/MSP version 5 patch to run with this example:
|
||||
|
||||
----------begin_max5_patcher----------
|
||||
3365.3oc4bk0iiaiD9Y2+J3JLOrAq6Fhj5LOscRP.lGxtCxDr6CYBFHaQaqL
|
||||
xRNRzcOcBx+8s3grkZac31Vr8jMASKScPU7qNXUTUw+3lIVyx+LqzB80neFM
|
||||
YxebyjIxSINwDc6IVqi977znR4sYMOe8ZVF2Zp5Zb1m4pyuJOujghPkrhjnT
|
||||
zl7BNZQQ9ZDeURIBdlsUOyh7LdYxuyDOGlbms9zYaWmjkx3x2Cd+Iy2xqNa0
|
||||
stIhOeUR1xOVvlyUTuuqOzSHRfs7fspEz.8K5GJIVRn4y90ao90okrn0RZw5
|
||||
dAkaItvedyMh+LcffRF6QnaO.SzPQnmsM5eFskmmugkgrOebfzNNPbbDibJU
|
||||
hCXG2tvArSEsn5b9SaXptwJQviQVV6drKCRslUVFsjcn3SJH8bJ.C4n.Ctcf
|
||||
gRjhDTaO4gPI7DbbbgfaEWtz.RKhNR7XVT1xSASrOYLITJrfUG75VVwqULQR
|
||||
mlAWRyihOUXAepvhiGsNrX2ErPbtFfkMELvzRrzp6nBM9Dk5CUJq3G1IzDXL
|
||||
snsuz4WR3r054+rduzb86jPHxZp3OyxyWK92seS5VFX+lu5128c2e6s3c2w9
|
||||
K7C4wr0G47hG38OkMe2k99jB12m9zsgem+2b66e261CFMYCz1YCdJ7WaLiX2
|
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
||||
3GDPnthe43a6FD7rM8hZkCzgEmNVAOOuVhNNGXGybmcoYPDKh8ihr39cmV7z
|
||||
4fBRsAf8cjo09Se6UG9pMRMW+9WTeha26KES6+q5T0oKyxAZPH9VeLpXMMFK
|
||||
MJLq5iEI.oJBLu8Ufm.OZ77fOQ1Rn34+P1W+kPXrawJ7qhXkOUMireP+hUgz
|
||||
+BKVI63l4SoRJ644ofVV6f7SPrNA6SOkVxMARijz4v7R334jvAR9mDM4zCMQ
|
||||
MJIQaj1LsASglGlr6ilLKN4ZO.ZBaaTZxe.jD08zHIhuiHwD7v5HCB105LI1
|
||||
fAPr9FE9bF.EEXTJBODgLmSjgpXgtjPYBmnXuxVWBhkbgIVM4o+9n0ZctDKd
|
||||
Hpulc1.5P31Dr4oo9lN.a1oCFDuidhldItTUBXo2ze8105bmnfN.p08DoVGa
|
||||
o1qiCtlUYYqyjZ8HCAaMK+dH.njtIlyiDxPoIr4noAiSFzKoAI76ZVZxcHzj
|
||||
yKSgTsEm53Enxxs5snpsA.8cJaYhILbMqSTtCwIT2SzWcJUNwuCtNBJactl6
|
||||
F.wFd8ow38BmsvSI4Q205b8XNXDX1mK.ND23cLqe7CI9Uri4iy+RSSUgG5p+
|
||||
HIpz3nQKZUBfJEBksNW2AcFp8b7I6NnNwkbbb10xHTqsY8b.OBxBZWnopDbs
|
||||
BOIm+BGfGCsIpqTxkZqhBPSshVmK0RGCp0OPE7taMpU15boVxUnkJ7PVQRyZ
|
||||
PmNnvjLbn5zqPZZHV6nFdYVFhSeT5UHMYV8Nr2HrbTNZCrNXoAV8xrHZctyg
|
||||
MDIM7IxUE6mpR5SM8u1pqn0kvKf9roQ8N0YETQVpJnPOhptBazRteTK1KOcT
|
||||
a+8meDTjfQXFCepaMuunggpQRiV5jcsxuB+C9dg27m27+.7QBpFG
|
||||
-----------end_max5_patcher-----------
|
||||
|
||||
*/
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
String constructors
|
||||
|
||||
Examples of how to create strings from other data types
|
||||
|
||||
created 27 July 2010
|
||||
modified 30 Aug 2011
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringConstructors
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// using a constant String:
|
||||
String stringOne = "Hello String";
|
||||
Serial.println(stringOne); // prints "Hello String"
|
||||
|
||||
// converting a constant char into a String:
|
||||
stringOne = String('a');
|
||||
Serial.println(stringOne); // prints "a"
|
||||
|
||||
// converting a constant string into a String object:
|
||||
String stringTwo = String("This is a string");
|
||||
Serial.println(stringTwo); // prints "This is a string"
|
||||
|
||||
// concatenating two strings:
|
||||
stringOne = String(stringTwo + " with more");
|
||||
// prints "This is a string with more":
|
||||
Serial.println(stringOne);
|
||||
|
||||
// using a constant integer:
|
||||
stringOne = String(13);
|
||||
Serial.println(stringOne); // prints "13"
|
||||
|
||||
// using an int and a base:
|
||||
stringOne = String(analogRead(A0), DEC);
|
||||
// prints "453" or whatever the value of analogRead(A0) is
|
||||
Serial.println(stringOne);
|
||||
|
||||
// using an int and a base (hexadecimal):
|
||||
stringOne = String(45, HEX);
|
||||
// prints "2d", which is the hexadecimal version of decimal 45:
|
||||
Serial.println(stringOne);
|
||||
|
||||
// using an int and a base (binary)
|
||||
stringOne = String(255, BIN);
|
||||
// prints "11111111" which is the binary value of 255
|
||||
Serial.println(stringOne);
|
||||
|
||||
// using a long and a base:
|
||||
stringOne = String(millis(), DEC);
|
||||
// prints "123456" or whatever the value of millis() is:
|
||||
Serial.println(stringOne);
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
String replace()
|
||||
|
||||
Examples of how to replace characters or substrings of a string
|
||||
|
||||
created 27 July 2010
|
||||
by Tom Igoe
|
||||
|
||||
http://arduino.cc/en/Tutorial/StringReplace
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("\n\nString replace:");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
String stringOne = "<html><head><body>";
|
||||
Serial.println(stringOne);
|
||||
// replace() changes all instances of one substring with another:
|
||||
String stringTwo = stringOne.replace("<", "</");
|
||||
Serial.println(stringTwo);
|
||||
|
||||
// you can also use replace() on single characters:
|
||||
String normalString = "bookkeeper";
|
||||
Serial.println("normal: " + normalString);
|
||||
String leetString = normalString.replace('o', '0');
|
||||
leetString = leetString.replace('e', '3');
|
||||
Serial.println("l33tspeak: " + leetString);
|
||||
|
||||
// do nothing while true:
|
||||
while(true);
|
||||
}
|
@ -1,230 +0,0 @@
|
||||
/*
|
||||
Serial RGB controller
|
||||
|
||||
Reads a serial input string looking for three comma-separated
|
||||
integers with a newline at the end. Values should be between
|
||||
0 and 255. The sketch uses those values to set the color
|
||||
of an RGB LED attached to pins 9 - 11.
|
||||
|
||||
The circuit:
|
||||
* Common-anode RGB LED cathodes attached to pins 9 - 11
|
||||
* LED anode connected to pin 13
|
||||
|
||||
To turn on any given channel, set the pin LOW.
|
||||
To turn off, set the pin HIGH. The higher the analogWrite level,
|
||||
the lower the brightness.
|
||||
|
||||
created 29 Nov 2010
|
||||
by Tom Igoe
|
||||
|
||||
This example code is in the public domain.
|
||||
*/
|
||||
|
||||
String inString = ""; // string to hold input
|
||||
int currentColor = 0;
|
||||
int red, green, blue = 0;
|
||||
|
||||
void setup() {
|
||||
// Initialize serial communications:
|
||||
Serial.begin(9600);
|
||||
// set LED cathode pins as outputs:
|
||||
pinMode(9, OUTPUT);
|
||||
pinMode(10, OUTPUT);
|
||||
pinMode(11, OUTPUT);
|
||||
// turn on pin 13 to power the LEDs:
|
||||
pinMode(13, OUTPUT);
|
||||
digitalWrite(13, HIGH);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int inChar;
|
||||
|
||||
// Read serial input:
|
||||
if (Serial.available() > 0) {
|
||||
inChar = Serial.read();
|
||||
}
|
||||
|
||||
if (isDigit(inChar)) {
|
||||
// convert the incoming byte to a char
|
||||
// and add it to the string:
|
||||
inString += (char)inChar;
|
||||
}
|
||||
|
||||
// if you get a comma, convert to a number,
|
||||
// set the appropriate color, and increment
|
||||
// the color counter:
|
||||
if (inChar == ',') {
|
||||
// do something different for each value of currentColor:
|
||||
switch (currentColor) {
|
||||
case 0: // 0 = red
|
||||
red = inString.toInt();
|
||||
// clear the string for new input:
|
||||
inString = "";
|
||||
break;
|
||||
case 1: // 1 = green:
|
||||
green = inString.toInt();
|
||||
// clear the string for new input:
|
||||
inString = "";
|
||||
break;
|
||||
}
|
||||
currentColor++;
|
||||
}
|
||||
// if you get a newline, you know you've got
|
||||
// the last color, i.e. blue:
|
||||
if (inChar == '\n') {
|
||||
blue = inString.toInt();
|
||||
|
||||
// set the levels of the LED.
|
||||
// subtract value from 255 because a higher
|
||||
// analogWrite level means a dimmer LED, since
|
||||
// you're raising the level on the anode:
|
||||
analogWrite(11, 255 - red);
|
||||
analogWrite(9, 255 - green);
|
||||
analogWrite(10, 255 - blue);
|
||||
|
||||
// print the colors:
|
||||
Serial.print("Red: ");
|
||||
Serial.print(red);
|
||||
Serial.print(", Green: ");
|
||||
Serial.print(green);
|
||||
Serial.print(", Blue: ");
|
||||
Serial.println(blue);
|
||||
|
||||
// clear the string for new input:
|
||||
inString = "";
|
||||
// reset the color counter:
|
||||
currentColor = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Here's a Processing sketch that will draw a color wheel and send a serial
|
||||
string with the color you click on:
|
||||
|
||||
// Subtractive Color Wheel with Serial
|
||||
// Based on a Processing example by Ira Greenberg.
|
||||
// Serial output added by Tom Igoe
|
||||
//
|
||||
// The primaries are red, yellow, and blue. The secondaries are green,
|
||||
// purple, and orange. The tertiaries are yellow-orange, red-orange,
|
||||
// red-purple, blue-purple, blue-green, and yellow-green.
|
||||
//
|
||||
// Create a shade or tint of the subtractive color wheel using
|
||||
// SHADE or TINT parameters.
|
||||
|
||||
// Updated 29 November 2010.
|
||||
|
||||
|
||||
|
||||
import processing.serial.*;
|
||||
|
||||
int segs = 12;
|
||||
int steps = 6;
|
||||
float rotAdjust = TWO_PI / segs / 2;
|
||||
float radius;
|
||||
float segWidth;
|
||||
float interval = TWO_PI / segs;
|
||||
|
||||
Serial myPort;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
background(127);
|
||||
smooth();
|
||||
ellipseMode(RADIUS);
|
||||
noStroke();
|
||||
// make the diameter 90% of the sketch area
|
||||
radius = min(width, height) * 0.45;
|
||||
segWidth = radius / steps;
|
||||
|
||||
// swap which line is commented out to draw the other version
|
||||
// drawTintWheel();
|
||||
drawShadeWheel();
|
||||
// open the first serial port in your computer's list
|
||||
myPort = new Serial(this, Serial.list()[0], 9600);
|
||||
}
|
||||
|
||||
|
||||
void drawShadeWheel() {
|
||||
for (int j = 0; j < steps; j++) {
|
||||
color[] cols = {
|
||||
color(255-(255/steps)*j, 255-(255/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/1.5)-((255/1.5)/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/2)-((255/2)/steps)*j, 0),
|
||||
color(255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j, 0),
|
||||
color(255-(255/steps)*j, 0, 0),
|
||||
color(255-(255/steps)*j, 0, (255/2)-((255/2)/steps)*j),
|
||||
color(255-(255/steps)*j, 0, 255-(255/steps)*j),
|
||||
color((255/2)-((255/2)/steps)*j, 0, 255-(255/steps)*j),
|
||||
color(0, 0, 255-(255/steps)*j),
|
||||
color(0, 255-(255/steps)*j, (255/2.5)-((255/2.5)/steps)*j),
|
||||
color(0, 255-(255/steps)*j, 0),
|
||||
color((255/2)-((255/2)/steps)*j, 255-(255/steps)*j, 0)
|
||||
};
|
||||
for (int i = 0; i < segs; i++) {
|
||||
fill(cols[i]);
|
||||
arc(width/2, height/2, radius, radius,
|
||||
interval*i+rotAdjust, interval*(i+1)+rotAdjust);
|
||||
}
|
||||
radius -= segWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void drawTintWheel() {
|
||||
for (int j = 0; j < steps; j++) {
|
||||
color[] cols = {
|
||||
color((255/steps)*j, (255/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/1.5)/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/2)/steps)*j, 0),
|
||||
color((255/steps)*j, ((255/2.5)/steps)*j, 0),
|
||||
color((255/steps)*j, 0, 0),
|
||||
color((255/steps)*j, 0, ((255/2)/steps)*j),
|
||||
color((255/steps)*j, 0, (255/steps)*j),
|
||||
color(((255/2)/steps)*j, 0, (255/steps)*j),
|
||||
color(0, 0, (255/steps)*j),
|
||||
color(0, (255/steps)*j, ((255/2.5)/steps)*j),
|
||||
color(0, (255/steps)*j, 0),
|
||||
color(((255/2)/steps)*j, (255/steps)*j, 0)
|
||||
};
|
||||
for (int i = 0; i < segs; i++) {
|
||||
fill(cols[i]);
|
||||
arc(width/2, height/2, radius, radius,
|
||||
interval*i+rotAdjust, interval*(i+1)+rotAdjust);
|
||||
}
|
||||
radius -= segWidth;
|
||||
}
|
||||
}
|
||||
|
||||
void draw() {
|
||||
// nothing happens here
|
||||
}
|
||||
|
||||
void mouseReleased() {
|
||||
// get the color of the mouse position's pixel:
|
||||
color targetColor = get(mouseX, mouseY);
|
||||
// get the component values:
|
||||
int r = int(red(targetColor));
|
||||
int g = int(green(targetColor));
|
||||
int b = int(blue(targetColor));
|
||||
// make a comma-separated string:
|
||||
String colorString = r + "," + g + "," + b + "\n";
|
||||
// send it out the serial port:
|
||||
myPort.write(colorString );
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
void pulse(int pin, int times);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.begin(19200);
|
||||
pinMode(LED_PMODE, OUTPUT);
|
||||
pulse(LED_PMODE, 2);
|
||||
pinMode(LED_ERR, OUTPUT);
|
||||
@ -109,7 +109,7 @@ void heartbeat() {
|
||||
if (hbval < 32) hbdelta = -hbdelta;
|
||||
hbval += hbdelta;
|
||||
analogWrite(LED_HB, hbval);
|
||||
delay(40);
|
||||
delay(20);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
HIGH LITERAL1 Constants
|
||||
LOW LITERAL1 Constants
|
||||
INPUT LITERAL1 Constants
|
||||
INPUT_PULLUP LITERAL1 Constants
|
||||
OUTPUT LITERAL1 Constants
|
||||
DEC LITERAL1 Serial_Print
|
||||
BIN LITERAL1 Serial_Print
|
||||
@ -30,6 +31,7 @@ byte KEYWORD1 Byte
|
||||
case KEYWORD1 SwitchCase
|
||||
char KEYWORD1 Char
|
||||
class KEYWORD1
|
||||
const KEYWORD1 Const
|
||||
continue KEYWORD1 Continue
|
||||
default KEYWORD1 SwitchCase
|
||||
do KEYWORD1 DoWhile
|
||||
@ -181,5 +183,17 @@ parseFloat KEYWORD2
|
||||
readBytes KEYWORD2
|
||||
readBytesUntil KEYWORD2
|
||||
|
||||
# USB-related keywords
|
||||
|
||||
Keyboard KEYWORD3
|
||||
Mouse KEYWORD3
|
||||
press KEYWORD2
|
||||
release KEYWORD2
|
||||
releaseAll KEYWORD2
|
||||
accept KEYWORD2
|
||||
click KEYWORD2
|
||||
move KEYWORD2
|
||||
isPressed KEYWORD2
|
||||
|
||||
setup KEYWORD3 Setup
|
||||
loop KEYWORD3 Loop
|
||||
|
@ -76,11 +76,16 @@ editor.window.width.default = 500
|
||||
editor.window.height.default = 600
|
||||
|
||||
editor.window.width.min = 400
|
||||
editor.window.height.min = 500
|
||||
editor.window.height.min = 290
|
||||
|
||||
# the following commented out to better support netbooks
|
||||
# http://code.google.com/p/arduino/issues/detail?id=52
|
||||
#editor.window.height.min = 500
|
||||
# tested as approx 440 on OS X
|
||||
editor.window.height.min.macosx = 450
|
||||
#editor.window.height.min.macosx = 450
|
||||
# tested to be 515 on Windows XP, this leaves some room
|
||||
editor.window.height.min.windows = 530
|
||||
#editor.window.height.min.windows = 530
|
||||
|
||||
|
||||
# font size for editor
|
||||
editor.font=Monospaced,plain,12
|
||||
@ -245,9 +250,15 @@ software=ARDUINO
|
||||
programmer = arduino:avrispmkii
|
||||
|
||||
upload.using = bootloader
|
||||
upload.verify = true
|
||||
|
||||
serial.port=COM1
|
||||
serial.databits=8
|
||||
serial.stopbits=1
|
||||
serial.parity=N
|
||||
serial.debug_rate=9600
|
||||
|
||||
# I18 Preferences
|
||||
|
||||
# default chosen language (none for none)
|
||||
editor.languages.current =
|
||||
|
Binary file not shown.
@ -1,3 +1,122 @@
|
||||
ARDUINO 1.0.1 - 2012.05.21
|
||||
|
||||
[environment]
|
||||
|
||||
* The IDE has been internationalized and translated into multiple languages.
|
||||
Thanks to Shigeru Kanemoto for the internationalization and Japanese
|
||||
translation and many others for the other translations. For more
|
||||
information, see: http://arduino.cc/playground/Main/LanguagesIDE
|
||||
|
||||
* Added preference for selecting the language in which to display the
|
||||
Arduino software. Defaults to the operating system locale.
|
||||
|
||||
* New upload process for the Arduino Leonardo (ATmega32U4).
|
||||
|
||||
* The editor font size preference now applies to the serial monitor and
|
||||
error / message console as well as the editor. (Paul Stoffregen)
|
||||
http://code.google.com/p/arduino/issues/detail?id=550
|
||||
|
||||
* Compilation has been speeded up by only compiling changed files. (All
|
||||
files are recompiled when a new board is selected.) (Paul Stoffregen)
|
||||
http://code.google.com/p/arduino/issues/detail?id=638
|
||||
|
||||
* Console log files (stdout.txt and stderr.txt) are now removed when the
|
||||
Arduino software exits. (Paul Stoffregen)
|
||||
|
||||
* The minimum size for the Arduino software window has been reduced.
|
||||
http://code.google.com/p/arduino/issues/detail?id=52
|
||||
|
||||
* Improvements to the Find / Replace dialog. (Peter Lewis)
|
||||
http://code.google.com/p/arduino/issues/detail?id=825
|
||||
|
||||
* Support for selecting words (on double-click) and lines (triple-click)
|
||||
in the Arduino software. (Peter Lewis)
|
||||
http://code.google.com/p/arduino/issues/detail?id=824
|
||||
|
||||
* Don't insert newline when using serial monitor keyboard
|
||||
shortcut. (Lars J. Nielsen)
|
||||
http://code.google.com/p/arduino/issues/detail?id=279
|
||||
|
||||
* Added a preference for disabling verification on upload (for increased
|
||||
speed). (Nathan Seidle)
|
||||
http://code.google.com/p/arduino/issues/detail?id=842
|
||||
|
||||
* Added the gcc toolchain to the Linux distribution. (To use the
|
||||
toolchain already installed on your system, simply delete the one
|
||||
that comes with the Arduino software.) (Paul Stoffregen)
|
||||
http://code.google.com/p/arduino/issues/detail?id=300
|
||||
|
||||
* Updating Arduino Mini upload protocol to 'arduino' from 'stk500' (should
|
||||
fix problems with auto-reset not working).
|
||||
|
||||
[core / libraries]
|
||||
|
||||
* Updated (and official) support for the Arduino Leonardo (ATmega32U4).
|
||||
Includes new bootloader and various fixes to the core.
|
||||
|
||||
* Adding overloads to Wire.write() (for Wire.write(0)). (Paul Stoffregen)
|
||||
http://code.google.com/p/arduino/issues/detail?id=527
|
||||
|
||||
* Fixing delayMicroseconds() for 20 MHz clocks (Erdem U. Altinyurt)
|
||||
http://code.google.com/p/arduino/issues/detail?id=306
|
||||
|
||||
* Support third external interrupt on ATmega1284P. (maniacbug)
|
||||
http://code.google.com/p/arduino/issues/detail?id=728
|
||||
|
||||
* Update reference voltage constants for ATmega1284P. (maniacbug)
|
||||
http://code.google.com/p/arduino/issues/detail?id=728
|
||||
|
||||
* Adding --relax linker flag for ATmega2560. (arducopter)
|
||||
http://code.google.com/p/arduino/issues/detail?id=729
|
||||
|
||||
* Fixing Ethernet library bug on avr-gcc 4.5.1 (SurferTim)
|
||||
http://code.google.com/p/arduino/issues/detail?id=605
|
||||
|
||||
* Fixed DHCP hostname generation. (peter)
|
||||
|
||||
* Simplifying microseconds to clock cycles conversions (Rob Tillaart)
|
||||
http://code.google.com/p/arduino/issues/detail?id=675
|
||||
|
||||
* Fixed various warnings. (maniacbug)
|
||||
http://code.google.com/p/arduino/issues/detail?id=688
|
||||
|
||||
* Fixed bug w/ repeated initial characters in findUntil(). (Jeffery.zksun)
|
||||
http://code.google.com/p/arduino/issues/detail?id=768
|
||||
|
||||
* Added INPUT_PULLUP option for pinMode(). The INPUT mode now explicitly
|
||||
disables the pullup resistors. (Paul Stoffregen)
|
||||
http://code.google.com/p/arduino/issues/detail?id=246
|
||||
|
||||
* Fixing bug in the receiving of multiple UDP packets. (dylan and peter)
|
||||
http://code.google.com/p/arduino/issues/detail?id=669
|
||||
|
||||
* Added ability to generate repeated starts in the Wire library (in
|
||||
master mode). Extra boolean parameters to endTransmission() and
|
||||
requestFrom() control whether or not to send a stop (or a repeated
|
||||
start instead). (Todd Krein)
|
||||
http://code.google.com/p/arduino/issues/detail?id=663
|
||||
|
||||
* Added Ethernet.maintain() to renew DHCP leases. (Peter Magnusson)
|
||||
http://code.google.com/p/arduino/issues/detail?id=716
|
||||
|
||||
* Fix for CLOSE_WAIT bug that could cause Ethernet sketches to crash
|
||||
over time. (mr-russ and Johann Richard)
|
||||
|
||||
* Fix to servo pulse timing calculation. (jwatte)
|
||||
http://code.google.com/p/arduino/issues/detail?id=908
|
||||
|
||||
* Added readString() and readStringUntil() functions. (Adrian McEwen)
|
||||
http://code.google.com/p/arduino/issues/detail?id=454
|
||||
|
||||
[examples]
|
||||
|
||||
* Updated to latest ArduinoISP sketch. (rsbohn)
|
||||
http://code.google.com/p/arduino/issues/detail?id=378
|
||||
|
||||
* Fixed ArduinoISP sketch by lowering delay() in heartbeat.
|
||||
|
||||
* Other updates.
|
||||
|
||||
ARDUINO 1.0 - 2011.11.30
|
||||
|
||||
[environment]
|
||||
|
@ -86,13 +86,12 @@ ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
[SourceDisksFiles]
|
||||
[SourceDisksNames]
|
||||
[DeviceList]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0032
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0034&MI_00
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0036
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_8036&MI_00
|
||||
|
||||
[DeviceList.NTamd64]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0032
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0034&MI_00
|
||||
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_0036
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_8036&MI_00
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; String Definitions
|
||||
|
106
build/windows/dist/drivers/Arduino USBSerial.inf
vendored
Normal file
106
build/windows/dist/drivers/Arduino USBSerial.inf
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
;************************************************************
|
||||
; Windows USB CDC ACM Setup File
|
||||
; Copyright (c) 2000 Microsoft Corporation
|
||||
|
||||
|
||||
[Version]
|
||||
Signature="$Windows NT$"
|
||||
Class=Ports
|
||||
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
|
||||
Provider=%MFGNAME%
|
||||
LayoutFile=layout.inf
|
||||
CatalogFile=%MFGFILENAME%.cat
|
||||
DriverVer=11/15/2007,5.1.2600.0
|
||||
|
||||
[Manufacturer]
|
||||
%MFGNAME%=DeviceList, NTamd64
|
||||
|
||||
[DestinationDirs]
|
||||
DefaultDestDir=12
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Windows 2000/XP/Vista-32bit Sections
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
[DriverInstall.nt]
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=DriverCopyFiles.nt
|
||||
AddReg=DriverInstall.nt.AddReg
|
||||
|
||||
[DriverCopyFiles.nt]
|
||||
usbser.sys,,,0x20
|
||||
|
||||
[DriverInstall.nt.AddReg]
|
||||
HKR,,DevLoader,,*ntkern
|
||||
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[DriverInstall.nt.Services]
|
||||
AddService=usbser, 0x00000002, DriverService.nt
|
||||
|
||||
[DriverService.nt]
|
||||
DisplayName=%SERVICE%
|
||||
ServiceType=1
|
||||
StartType=3
|
||||
ErrorControl=1
|
||||
ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vista-64bit Sections
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
[DriverInstall.NTamd64]
|
||||
include=mdmcpq.inf
|
||||
CopyFiles=DriverCopyFiles.NTamd64
|
||||
AddReg=DriverInstall.NTamd64.AddReg
|
||||
|
||||
[DriverCopyFiles.NTamd64]
|
||||
%DRIVERFILENAME%.sys,,,0x20
|
||||
|
||||
[DriverInstall.NTamd64.AddReg]
|
||||
HKR,,DevLoader,,*ntkern
|
||||
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[DriverInstall.NTamd64.Services]
|
||||
AddService=usbser, 0x00000002, DriverService.NTamd64
|
||||
|
||||
[DriverService.NTamd64]
|
||||
DisplayName=%SERVICE%
|
||||
ServiceType=1
|
||||
StartType=3
|
||||
ErrorControl=1
|
||||
ServiceBinary=%12%\%DRIVERFILENAME%.sys
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; Vendor and Product ID Definitions
|
||||
;------------------------------------------------------------------------------
|
||||
; When developing your USB device, the VID and PID used in the PC side
|
||||
; application program and the firmware on the microcontroller must match.
|
||||
; Modify the below line to use your VID and PID. Use the format as shown below.
|
||||
; Note: One INF file can be used for multiple devices with different VID and PIDs.
|
||||
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
|
||||
;------------------------------------------------------------------------------
|
||||
[SourceDisksFiles]
|
||||
[SourceDisksNames]
|
||||
[DeviceList]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_003B
|
||||
|
||||
[DeviceList.NTamd64]
|
||||
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_003B
|
||||
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; String Definitions
|
||||
;------------------------------------------------------------------------------
|
||||
;Modify these strings to customize your device
|
||||
;------------------------------------------------------------------------------
|
||||
[Strings]
|
||||
MFGFILENAME="CDC_vista"
|
||||
DRIVERFILENAME ="usbser"
|
||||
MFGNAME="Arduino LLC (www.arduino.cc)"
|
||||
INSTDISK="Arduino USBSerial Driver Installer"
|
||||
DESCRIPTION="Arduino UNO"
|
||||
SERVICE="USB RS-232 Emulation Driver"
|
Reference in New Issue
Block a user