1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-18 12:54:25 +01:00

Cleaned up examples (new Serial lib, etc)

This commit is contained in:
David A. Mellis 2006-04-26 16:57:14 +00:00
parent 260c5d5ee1
commit 53a6afd3f6
6 changed files with 143 additions and 137 deletions

View File

@ -130,18 +130,18 @@ void printBuff(){
////////////////////////////////////////////
void readBuff(){
printString("into readbuff method");
serialVal = serialRead();
Serial.print("into readbuff method");
serialVal = Serial.read();
if (serialVal != -1){
printString("information there");
Serial.print("information there");
if ((serialVal == 43) && !reading){
reading = true;
printString("plus");
Serial.print("plus");
}
if ((serialVal == 45) && (times == 0 && reading)){
writing = true;
printString("minus");
Serial.print("minus");
}
if (reading && writing){
@ -150,7 +150,7 @@ void readBuff(){
}
if (times >= 7){
printString("Print to buff");
Serial.print("Print to buff");
times = 0;
reading = false;
writing = false;
@ -179,6 +179,7 @@ void max7219_init()
// program initialization routine
void setup()
{
Serial.begin(9600);
setPinModes();
max7219_init();
}
@ -186,7 +187,7 @@ void setup()
// program loop
void loop()
{
printString("in the loop");
Serial.print("in the loop");
//max7219_all(0x00);
//delay(500);
readBuff();

View File

@ -35,7 +35,7 @@ int dato = 0; // dato is a varible we use to send data to the LEDs
void setup()
{
//beginSerial(9600); // uncomment the serial-related lines to monitor the program's progress
//Serial.begin(9600); // uncomment the serial-related lines to monitor the program's progress
pinMode(data, OUTPUT); // declare all the control pins as outputs
pinMode(clock, OUTPUT);
pinMode(strob, OUTPUT);
@ -60,7 +60,7 @@ void loop()
// go through the "dato" variable and send it bit by bit over the data pin
for (count = 0; count < 8; count++) {
digitalWrite(data, dato & 01);
//serialWrite((dato & 01) + 48);
//Serial.print((dato & 01) + 48, BYTE);
dato>>=1;
if (count == 7){
digitalWrite(oe, LOW);
@ -74,6 +74,6 @@ void loop()
digitalWrite(strob, LOW);
delay(100);
//printNewline();
//Serial.println();
delay(100); // waits for a second
}

View File

@ -15,7 +15,7 @@ int potPin = 0; // analog pin where to plug the potentiometer at
void setup() {
pinMode(motorPin, OUTPUT); // declare the motor as an output
beginSerial(9600); // connect to the serial port to send values back
Serial.begin(9600); // connect to the serial port to send values back
}
void loop() {
@ -23,8 +23,7 @@ void loop() {
value = analogRead(potPin);
// print its value back to the computer
printInteger(value);
printNewline();
Serial.println(value);
// turn the motor on
digitalWrite(motorPin,HIGH);

View File

@ -18,6 +18,7 @@
*/
int ledPin0 = 13; // LED connected to digital pin 13
boolean ledValue = LOW;
int motorPin1 = 9; // Motor 1 connected to digital pin 9
int motorPin2 = 8; // Motor 1 connected to digital pin 8
@ -45,7 +46,12 @@
*/
boolean boolSwitch (boolean *target)
{
if ( *target ) {*target = false;} else { *target = true; }
if ( *target ) {
*target = false;
}
else {
*target = true;
}
return *target;
}
@ -73,7 +79,7 @@ void loop()
// blink time to 1 sec, we are able to scanning inputs each 100 msec.
if (counter++ >= 10)
{
digitalWrite (ledPin0, boolSwitch (ledPin0)); // Led blink each 10 scan cycles i.e. if
digitalWrite (ledPin0, boolSwitch (&ledValue)); // Led blink each 10 scan cycles i.e. if
// led is on 1 second, we are scaning knobs each
// 100 miliseconds
counter =0;

View File

@ -30,7 +30,7 @@ void readSerialString (char *strArray) {
while (serialAvailable()){
strArray[i] = Serial.read();
i++;
Serial.write(strArray[(i-1)]); //optional: for confirmation
Serial.print(strArray[(i-1)]); //optional: for confirmation
}
Serial.println(); //optional: for confirmation
}

View File

@ -26,7 +26,7 @@ void loop () {
// if the input is '-1' then there is no data
// at the input, otherwise store it
if (val != -1) {
if (serbyte != -1) {
val = serbyte;
}