Project 1 — Arduino Uno simulation

An interactive Arduino Uno circuit simulation you can run free in your browser on Velxio, by agaleanoo.

Components

Sketch code

// Blink LED Example
// Toggles the built-in LED on pin 13
int a=0;
int valor=0;
const int pinPWM = 9;
const int LED1 =13;
int paso1 =0; 
int TOTAL_PASOS_1=10;
unsigned long tiempo1 = 0;
const unsigned long DELAY_1 = 500;
unsigned long tiempo2 = 0;
const unsigned long DELAY_2= 20;

void setup() {
  pinMode(13, OUTPUT);
  Serial.begin(115200);
  pinMode(pinPWM, OUTPUT);

}

  void loop() {
 
  secuencia_1();
  secuencia_2();
  //secuencia_3();
}


void secuencia_1(){

    
 if (millis() - tiempo1 >= DELAY_1) {
  tiempo1 = millis();
  digitalWrite(LED1, paso1 % 2 == 0 ? HIGH : LOW);
  paso1++;
  Serial.println(tiempo1);
 }

   if (paso1 >= TOTAL_PASOS_1) {
    paso1 = 0;
   }
  
}

void secuencia_2(){

     // Incremento gradual del PWM
      if (millis() - tiempo2 >= DELAY_2) {
      tiempo2 = millis();
      valor++;
      analogWrite(pinPWM, valor);
      Serial.println(valor);
      }
     if (valor >= 255) {
      // Decremento gradual del PWM
       while (valor >= 0) {
    if (millis() - tiempo2 >= DELAY_2) {
      tiempo2 = millis();
      valor--;
      analogWrite(pinPWM, valor);
      Serial.println(valor);
  }
   }

  } }

More projects by agaleanoo