Librerías \ TimedAction

Referencia para la versión de Wiring 1.0 Build 0100+. Si tiene una versión previa, use la referencia incluida con su software. Si encuentra errores o tiene comentarios, no dude en contactarnos.

Clase

TimedAction

Nombre

disable()

Ejemplos
#include <TimedAction.h>

//this initializes a TimedAction object that will change 
//the state of an LED every second.
TimedAction blinkAction =	TimedAction(1000,blink);
//this initializes a TimedAction object that will change 
//the state of an LED 
//according to the serial buffer contents, every 50 milliseconds
TimedAction physicalPixelAction = TimedAction(50,physicalPixel);
//this initializes a TimedAction object that will write 
//the ascii table to the serial every ten seconds
TimedAction asciiTableAction = TimedAction(10000,asciiTable); 

// pin state variables
const byte ledPin = 13;
const byte physicalPin = 12;

boolean ledState = false;

void setup()
{
  pinMode(ledPin,OUTPUT);
  digitalWrite(ledPin,ledState);
  pinMode(physicalPin, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  blinkAction.check(); //trigger every second
  physicalPixelAction.check(); //trigger every 50 millisecond
  asciiTableAction.check(); //trigger once in 10 seconds
}

void blink()
{
  ledState ? ledState=false : ledState=true;
  digitalWrite(ledPin,ledState);
}

void physicalPixel()
{
  if (Serial.available()) 
  {
    byte val = Serial.read();
    if (val == 'H') 
    {
      digitalWrite(physicalPin, HIGH);
    } 
    if (val == 'L') 
    {
      digitalWrite(physicalPin, LOW);
    }
  }
}

void asciiTable() 
{ 
  byte number = 33; // first visible character '!' is #33 
  // print until we have printed last visible character '~' #126 ... 
  while(number &lt;= 126) 
  { 
    Serial.print(number, BYTE);    // prints value unaltered, first will be '!' 
      
    Serial.print(", dec: "); 
    Serial.print(number);          // prints value as string in decimal (base 10) 
	// this also works 
    // Serial.print(number, DEC);  
    Serial.print(", hex: "); 
    Serial.print(number, HEX);     // prints value as string in hexadecimal (base 16) 
      
    Serial.print(", oct: "); 
    Serial.print(number, OCT);     // prints value as string in octal (base 8) 
      
    Serial.print(", bin: "); 
    Serial.println(number, BIN);   // prints value as string in binary (base 2) 
                                   // also prints ending line break 
    number++; // to the next character 
  } 
  asciiTableAction.disable();
}
Descripción Deshabilita el llamado de TimedAction.
Sintaxis
disable()
Retorna Ninguno
Uso Application
Updated on July 07, 2011 11:16:41pm PDT

Creative Commons License