Robótica Livre
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Ir para baixo
Gabriel Novak
Gabriel Novak
Mensagens : 80
Data de inscrição : 12/03/2022
Idade : 99
Escola : Colegio Esatadual Professor Lindaura Ribeiro Lucas

exercicio 2.03 Empty exercicio 2.03

Ter Nov 01, 2022 9:44 am
/*
* CURSO DE ROBOTICA 2020
*
* Exercicio: 2.3
* Tema: Função IF / ELSE
* Atividade: Acender um LED se a luminosidade for muito elevada, acima de 500 lux Smile
* Descrição: Usar uma entrada analógica para medir a intensidade da luz e usar esse valor para acender um LED
* Hardware: Ligar os leds nos pino digitais configurado como SAÍDA DIGITAL e o LDR em uma entrada analógica
* Comandos: pinMode, analogRead, digitalWrite,delay, map, IF
* Dica1:A o conversor analógico possui 10 bits ou seja de 0 até 1024
* Dica2:Usar a função if() para comparar se o valor do LDR ultrapassar determinado valor acender o LED e se baixar o valor apagar o LED
*/

//DEFINICOES INICIAIS
#define led5 3// definir pino 3 como led5
#define LDR A0//definir pino A0

//DECLARAcAO DE VARIAVEIS GLOBAIS
int luminosidade;//variavel int nomeada de luminosidade

//INICIALIZAÇÃO DO HARDWARE
void setup() {
pinMode(led5, OUTPUT);//definir led5vomo saida
Serial.begin(9600);//abrir porta cereal
}

//FUNÇÕES COMPLEMENTARES


//PROGRAMA PRINCIPAL
void loop() {
luminosidade = analogRead(LDR);//vareavel = ldr
Serial.println(luminosidade);//passar o valor de luminosidade na porta cereal
delay(200);//delay de 200 ms
if(luminosidade > 500){//"o valor de lumenosidade È maior de 500?"
digitalWrite(led5, HIGH);//sim
}else{
 digitalWrite(led5, LOW);//não
}
} Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy
Paulo Augusto Batista
Paulo Augusto Batista
Admin
Mensagens : 5788
Data de inscrição : 11/02/2019
Idade : 53
Escola : Colegio Lindaura
https://roboticalivre.forumeiros.com

exercicio 2.03 Empty Re: exercicio 2.03

Sex Nov 04, 2022 11:33 pm
Muito bom, nota 10.0
Ir para o topo
Permissões neste sub-fórum
Não podes responder a tópicos