Skip to content

Instantly share code, notes, and snippets.

@AlejandroVelasco
Created April 21, 2024 02:15
Show Gist options
  • Select an option

  • Save AlejandroVelasco/7e531c80f264e4d7b3f6b43394b82e7c to your computer and use it in GitHub Desktop.

Select an option

Save AlejandroVelasco/7e531c80f264e4d7b3f6b43394b82e7c to your computer and use it in GitHub Desktop.
int main() {
// Definir los números
int n1 = 10, n2 = 4, n3 = 6;
// Calcular la media aritmética
int media = (n1 + n2 + n3) / 3;
// Código para el microcontrolador, para demostrar el resultado.
DDRB |= (1 << PB5); // Establecer PB5 como salida
while (1) {
if (media >= 0 && media <= 255) {
PORTB |= (1 << PB5); // Encender LED si el resultado es válido
} else {
PORTB &= ~(1 << PB5); // Apagar LED si el resultado no es válido
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment