terça-feira, 16 de setembro de 2008

Fontes de Base para Projeto

/*
*
*
* leitura das portas analogicas
*
*/

// Output
int Vel1Pin = 9; // Velocidade 01 , esta no pino 09
int Vel2Pin = 10; // Velocidade 02 , esta no pino 10


// Program variables
int vel1 = 0; // Aqui seta-se os valores para incialização
int vel2 = 0; // deixa tudo desligado
int vel2 = 0;

int i = 0; // Loop counter
int wait = 50; // 50ms (.05 second) delay; shorten for faster fades
int DEBUG = 0; // DEBUG counter; if set to 1, will write values back via serial

void setup()
{
pinMode(redPin, OUTPUT); // sets the pins as output
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
if (DEBUG) { // If we want to see the pin values for debugging...
Serial.begin(9600); // ...set up the serial ouput on 0004 style
}
}

// Main program
void loop()
{
i += 1; // Increment counter
if (i < blueval =" 1;" redval =" 1;" greenval =" 1;" i =" 1;"> 10) // Print every 10 loops
{
DEBUG = 1; // Reset the counter

Serial.print(i); // Serial commands in 0004 style
Serial.print("\t"); // Print a tab
Serial.print("R:"); // Indicate that output is red value
Serial.print(redVal); // Print red value
Serial.print("\t"); // Print a tab
Serial.print("G:"); // Repeat for green and blue...
Serial.print(greenVal);
Serial.print("\t");
Serial.print("B:");
Serial.println(blueVal); // println, to end with a carriage return
}
}
delay(wait); // Pause for 'wait' milliseconds before resuming the loop
}











*****************************************************************************
/*
*
* Este codigo cria um delay sem a funcao de delay.
*
*
*/
int ledPin = 13; // LED connected to digital pin 13
int value = LOW; // previous value of the LED
long previousMillis = 0; // will store last time LED was updated
long interval = 1000; // interval at which to blink (milliseconds)

void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}

void loop()
{
// here is where you'd put code that needs to be running all the time.

// check to see if it's time to blink the LED; that is, is the difference
// between the current time and last time we blinked the LED bigger than
// the interval at which we want to blink the LED.
if (millis() - previousMillis > interval) {
previousMillis = millis(); // remember the last time we blinked the LED

// if the LED is off turn it on and vice-versa.
if (value == LOW)
value = HIGH;
else
value = LOW;

digitalWrite(ledPin, value);
}
}

Nenhum comentário: