0% found this document useful (0 votes)
4 views4 pages

Lista 2 Arduino

This document outlines three basic Arduino exercises to be completed on the Tinkercad platform. The exercises include creating a circuit with an RGB LED, building a proximity sensor, and controlling the brightness of an LED using a potentiometer. Each exercise includes the necessary code and setup instructions for implementation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Lista 2 Arduino

This document outlines three basic Arduino exercises to be completed on the Tinkercad platform. The exercises include creating a circuit with an RGB LED, building a proximity sensor, and controlling the brightness of an LED using a potentiometer. Each exercise includes the necessary code and setup instructions for implementation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lista 2 – Arduino Básico

Todos os exercícios deverão ser feitos na plataforma Tinkercad

https://www.tinkercad.com/

Exercício 1- Monte um circuito utilizando LED RGB.

Montagem

int red_light_pin= 11;


int green_light_pin = 10;
int blue_light_pin = 9;
void setup() {
pinMode(red_light_pin, OUTPUT);
pinMode(green_light_pin, OUTPUT);
pinMode(blue_light_pin, OUTPUT);
}
void loop() {
RGB_color(255, 0, 0); // Red
delay(1000);
RGB_color(0, 255, 0); // Green
delay(1000);
RGB_color(0, 0, 255); // Blue
delay(1000);
RGB_color(255, 255, 125); // Raspberry
delay(1000);
RGB_color(0, 255, 255); // Cyan
delay(1000);
RGB_color(255, 0, 255); // Magenta
delay(1000);
RGB_color(255, 255, 0); // Yellow
delay(1000);
RGB_color(255, 255, 255); // White
delay(1000);
}
void RGB_color(int red_light_value, int green_light_value, int
blue_light_value)
{
analogWrite(red_light_pin, red_light_value);
analogWrite(green_light_pin, green_light_value);
analogWrite(blue_light_pin, blue_light_value);
}

Exercício 2 – Faça um sensor de proximidade

Montagem
const int trigger=8;
const int echo=7;
float dist;

void setup(){
Serial.begin(9600);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
}

void loop(
digitalWrite(trigger,LOW);
delayMicroseconds(5);

digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);

dist=pulseIn(echo,HIGH);
dist = dist/58;

Serial.print ("Distancia = ");


Serial.print (dist);
Serial.print (" cm");
Serial.write (10);
delay (200);
}

Exercício 3 – Controle o brilho de um led com um potenciômetro.

void setup()
{
pinMode(A5, INPUT);
pinMode(10, OUTPUT);
}

void loop()
{
analogWrite(10, map(analogRead(A5), 0, 1023, 0, 255));
delay(10); // Delay a little bit to improve simulation performance
}

You might also like