Tabla de contenido

🔶 Introducción


📘 Fundamento Teórico


📖 Tema


📄 subtema

👩‍💻 Ejemplo


/*
  DATOS
*/
//Definiciones
//--Inputs
#define POT A0
//--Outputs
#define LED1 7
//Constantes
//Variables
int potValue = 0;
void setup()
{
  init_serial();
  init_IO();
}
void loop() //Bucle infinito
{
  potValue = analogRead(POT);
  Serial.print("potValue = ");
  Serial.println(potValue);
  delay(2);
}
void init_IO (void)
{
    //Init I/O
  //--Inputs
  pinMode (POT, INPUT);
  //--Output
  pinMode(LED1,OUTPUT);
  digitalWrite(LED1, LOW);
}
void init_serial(void)
{
  //Init serial
  Serial.begin(9600);//velocidad del monitor serial
}
/*
  DATOS
*/
//Definiciones
//--Inputs
#define POT A0
//--Outputs
#define LED1 6
#define LED2 5
//Constantes
//Variables
int potValue = 0;
int outputValue = 0;
void setup()
{
  init_serial();
  init_IO();
}
void loop() //Bucle infinito
{
  potValue = analogRead(POT);
  Serial.print("potValue = ");
  Serial.println(potValue);
  outputValue = map(potValue, 0, 1024, 0, 255);//10 bit ADC a 8 bits PWM
  analogWrite(LED1, outputValue);
  
  for (int i = 0; i <= 255 ;i++)
  {
   analogWrite(LED2, i); 
   delay(20);
  }
  
}
void init_IO (void)
{
    //Init I/O
  //--Inputs
  pinMode (POT, INPUT);
  
  //--Output
  pinMode(LED1,OUTPUT);
  digitalWrite(LED1, LOW);
  pinMode(LED2,OUTPUT);
  digitalWrite(LED2, LOW);
}
void init_serial(void)
{
  //Init serial
  Serial.begin(9600);//velocidad del monitor serial
}

🔸 Resumen


📓Actividad