Boa Tarde estou querendo fazer um alvo automatico usando apenas um servo motor igual a foto quando os 3 alvos for derrubados o servo gira 90º e levanta os alvos apos alguns segundos o servo retorna a posição inicial, poderia ser atraves de um controle remoto ou quando os 3 estivessem caidos dar uma passagem de 5v na entrada analogica e o arduino mandaria o servo para a posição de 90º alguem poderia me ajudar!
Grato
Tags:
Oi Sr. A. boa tarde.
Minha primeira ajuda: , , , , ,, ,.. ,,, . ,,
Use, e talvez consigamos entender seu texto e então ajudar.
Rui
Rui o que eu to querendo é o seguinte usando o arduino fazer um servo girar de 0 para 90 graus quando apertar a tecla 1 de um controle remoto via IR. quando apertar novamente essa tecla ele retorna. e um sensor LDR para quando estiver escuro os leds acenderem sozinhos de acordo com a luz ambiente, mas não sei colocar esses dois codigos em um só arduino você poderia me ajudar, achei um codigo para LDR e outro para Servo quase deu certo só não esta funcionando a parte do LDR ele não apaga os leds quando quando coloco luz isso virtual no 123Dcircuits
Codigo Fonte
#include <Servo.h>
/*
source: www.electroschematics.com
You'll need to change the led pins and the codes
accordingly to your configuration and IR remote
*/
#include <IRremote.h>
int RECV_PIN = 2; // the pin where you connect the output pin of TSOP4838
int led1 = 3;
int itsONled[] = {0,0,0,0,0,0,0,0,0,0};
/* the initial state of LEDs is OFF (zero)
the first zero must remain zero but you can
change the others to 1's if you want a certain
led to light when the board is powered */
#define code1 2295 // code received from button 1
#define LDR 0//
#define led 7
int val;// variá
IRrecv irrecv(RECV_PIN);
decode_results results;
Servo servoMain; // Define our Servo
void setup()
{
servoMain.attach(12); // servo on digital pin 10
Serial.begin(9600); // you can comment this line
irrecv.enableIRIn(); // Start the receiver
pinMode(led1, OUTPUT);
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop() {
if(irrecv.decode(&results)) {
unsigned int value = results.value;
switch(value) {
case code1:
if(itsONled[1] == 1) { // if first led is on then
digitalWrite(led1, LOW); // turn it off when button is pressed
servoMain.write(45); // Turn Servo Left to 45 degrees
itsONled[1] = 0; // and set its state as off
} else { // else if first led is off
digitalWrite(led1, HIGH); // turn it on when the button is pressed
servoMain.write(90); // Turn Servo Left to 45 degrees
itsONled[1] = 1; // and set its state as on
}
Serial.println(value); // you can comment this line
irrecv.resume(); // Receive the next value
val= analogRead(LDR); // ler os valores obtidos pelo ldr
Serial.println(val);
if (val <= 400) { // pouca luz - quase escuro
digitalWrite(led, HIGH);
}
if (val> 400) { // muita luz
digitalWrite(led, LOW);
}
delay(500);
}
}
}
Olá Adriano!
Tente fazer o seguinte:
Mude a linha
#define LDR 0//
Para
#define LDR A0
//Obs: A0 é a porta analógica zero
Acho que consegui entender, mas por favor coloque virgulas e pontos.
Reedite o texto e atualize-o, por favor.
Interessante essa aplicação !
Acho que poderia usar um servo para os alvos. Pensei em um came para fazer o levantamento dos mesmos.
https://en.wikipedia.org/wiki/Cam
E pode até usar um Arduino com sensor otico para contagem de pontos.
sim seria otimo, vou usar um servo mas usei um tubo de Ø4mm em forma de U que quando derrub os alvos ele apoiam nesse tubo ai o servo giraria 90 graus e levantaria os alvos .
estou quase conseguindo achei um codigo na net para o servo so nao estou conseguindo incluir linhas de comando nesse codigo para um LDR, queria que quando escurecer o LDR ligasse os leds para poder brincar no escuro juntei essas linhas de comando de dois codigos fontes a parte do servo ta funcionando agora do ldr ele nao esta funcionando vc poderia me ajudar.
Código Fonte
#include <Servo.h>
/*
source: www.electroschematics.com
You'll need to change the led pins and the codes
accordingly to your configuration and IR remote
*/
#include <IRremote.h>
int RECV_PIN = 2; // the pin where you connect the output pin of TSOP4838
int led1 = 3;
int itsONled[] = {0,0,0,0,0,0,0,0,0,0};
/* the initial state of LEDs is OFF (zero)
the first zero must remain zero but you can
change the others to 1's if you want a certain
led to light when the board is powered */
#define code1 2295 // code received from button 1
#define LDR 0//
#define led 7
int val;// variá
IRrecv irrecv(RECV_PIN);
decode_results results;
Servo servoMain; // Define our Servo
void setup()
{
servoMain.attach(12); // servo on digital pin 10
Serial.begin(9600); // you can comment this line
irrecv.enableIRIn(); // Start the receiver
pinMode(led1, OUTPUT);
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop() {
if(irrecv.decode(&results)) {
unsigned int value = results.value;
switch(value) {
case code1:
if(itsONled[1] == 1) { // if first led is on then
digitalWrite(led1, LOW); // turn it off when button is pressed
servoMain.write(45); // Turn Servo Left to 45 degrees
itsONled[1] = 0; // and set its state as off
} else { // else if first led is off
digitalWrite(led1, HIGH); // turn it on when the button is pressed
servoMain.write(90); // Turn Servo Left to 45 degrees
itsONled[1] = 1; // and set its state as on
}
Serial.println(value); // you can comment this line
irrecv.resume(); // Receive the next value
val= analogRead(LDR); // ler os valores obtidos pelo ldr
Serial.println(val);
if (val <= 400) { // pouca luz - quase escuro
digitalWrite(led, HIGH);
}
if (val> 400) { // muita luz
digitalWrite(led, LOW);
}
delay(500);
}
}
}
ola boa noite ja conseguiu, o codigo do ldr?
// Programa : LDR - Sensor de Iluminação
// Autor : Arduino e Cia
int Led = 13; //Porta a ser utilizada para ligar o led
int LDR = A11; //Porta analógica utilizada pelo LDR
void setup()
{
pinMode(Led, OUTPUT); //Define a porta do Led como saída
}
void loop()
{
int estado = analogRead(LDR); //Lê o valor fornecido pelo LDR
// Caso o valor lido na porta analógica seja maior do que
// 800, acende o LED
// Ajuste o valor abaixo de acordo com o seu circuito
if (estado > 800)
{
digitalWrite(Led, HIGH);
Serial.println(estado);
delay(1000);
}
else //Caso contrário, apaga o led
{
digitalWrite(Led, LOW);
Serial.println(estado);
delay(1000);
}
}
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por