Hola,
Estoy incursionando en Arduino de curioso y obteniendo información de diversos lugares.
Estoy preparando un juego para hacer tiro al blanco con un laser hacia un foto sensor; al acertar en él, el servomotor gira 90 grados y hace caer al blanco por un segundo. Son cuatro foto sensores con sus respectivos servos. El código funciona a la perfección hasta esta etapa.
Lo que necesito ahora son varias cosas que mis conocimientos no alcanzan a realizar.
- Necesito que el juego tenga un scoreboard, un contador de puntaje con un display de 7 segmentos (un solo dígito) que cuente desde el inicio del juego con un CERO y aumente de uno en uno cada vez que se le da al blanco, así hasta el número 9.
- Cuando termine el minuto de duracíón, los cuatro servos deben hace caer al blanco dando por culminado el juego, pero el display del marcado debe quedarse encendido con el puntaje alcanzado. Aquí necesito un botón de RESET para reiniciar el juego y otra persona juegue.
3.En mi código los cuatro servos se accionan y levantan los blancos al mismo tiempo. Sería ideal que ellos no se levanten al inicio en simultáneo, sino que se levanten aleatoriamente.
espero encontrar un gentil colaborador que pueda ayudarme con todo esto. Yo y mis sobrinos estaremos super agradecidos.
MUCHAS GRACIAS
Aqui va el codigo.
#include <Servo.h>
int sensorPin0 = A0;
int sensorPin1 = A1;
int sensorPin2 = A2;
int sensorPin3 = A3;
int sensor0Value;
int sensor1Value;
int sensor2Value;
int sensor3Value;
Servo myservo0; //Create an instance of the Servo object
Servo myservo1; //Create an instance of the Servo object
Servo myservo2; //Create an instance of the Servo object
Servo myservo3; //Create an instance of the Servo object
void setup()
{
myservo0.attach(2); //CONECTADO AL PIN 2 DE ARDUINO
myservo1.attach(3); //CONECTADO AL PIN 3 DE ARDUINO
myservo2.attach(4); //CONECTADO AL PIN 4 DE ARDUINO
myservo3.attach(5); //CONECTADO AL PIN 5 DE ARDUINO
}
void loop()
{
sensor0Value = analogRead(sensorPin0);
if (sensor0Value < 900) //SENSIBILIDAD DEL SENSOR A LA LUZ. CON LASER, OK. ****FALTA PROBAR BAJO EL SOL
{
myservo0.write(90); //INSTRUCCIÓN DE GIRAR 90 GRADOS
delay(15);
}
else
{
myservo0.write(0); //DESDE 0 GRADOS EMPEZARÁ
delay(1000); //DEMORA DEL BLANCO EN REGRESAR A LA POSICIÓN LEVANTADO
}
{
sensor1Value = analogRead(sensorPin1);
if (sensor1Value < 950) //SENSIBILIDAD DEL SENSOR A LA LUZ. CON LASER, OK. ****FALTA PROBAR BAJO EL SOL
{
myservo1.write(90); //INSTRUCCIÓN DE GIRAR 90 GRADOS
delay(15);
}
else
{
myservo1.write(0); //DESDE 0 GRADOS EMPEZARÁ
delay(1000); //DEMORA DEL BLANCO EN REGRESAR A LA POSICIÓN LEVANTADO
}
{
sensor2Value = analogRead(sensorPin2);
if (sensor2Value < 950) //SENSIBILIDAD DEL SENSOR A LA LUZ. CON LASER, OK. ****FALTA PROBAR BAJO EL SOL
{
myservo2.write(90); //INSTRUCCIÓN DE GIRAR 90 GRADOS
delay(15);
}
else
{
myservo2.write(0); //DESDE 0 GRADOS EMPEZARÁ
delay(1000); //DEMORA DEL BLANCO EN REGRESAR A LA POSICIÓN LEVANTADO
}
{
sensor3Value = analogRead(sensorPin3);
if (sensor3Value < 950) //SENSIBILIDAD DEL SENSOR A LA LUZ. CON LASER, OK. ****FALTA PROBAR BAJO EL SOL
{
myservo3.write(90); //INSTRUCCIÓN DE GIRAR 90 GRADOS
delay(15);
}
else
{
myservo3.write(0); //DESDE 0 GRADOS EMPEZARÁ
delay(1000); //DEMORA DEL BLANCO EN REGRESAR A LA POSICIÓN LEVANTADO
}
}}}}