## Sesc Av. Paulista
# Projetos em Eletrônica e Programação
## `hackmd.io/@sesc-av-paulista/projetos-ele-prog-2025`
## Terça 28 de maio de 2025
HORTA AUTOMÁTICA
// sinal do rele para válvula
int valvula = 8;
void setup() {
// declara válvula como saída
pinMode(valvula, OUTPUT);
Serial.begin(9600);
}
// Leitura do sensor no pino A0 e armazenamento em SensorValue
void loop() {
// verifica se valor de leitura está acima de 600 (umido abaixo de 600 e seco até 1023)
int sensorValue = analogRead(A0);
// se sim, libera água por 1s
if (sensorValue > 600){
digitalWrite(valvula,LOW);
delay(1000);
digitalWrite(valvula,HIGH); // desliga válvula
// se não, interrompe a passagem de água
} else{
digitalWrite(valvula,HIGH);
delay(1000);
}
Serial.println(sensorValue);
delay(3000); // Aguarda 3s para verificar se solo está umido novamente
}
```ino
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
}
```
## Terça 21 de maio de 2025
### Horta automática
### GPS Leandro
- Teste 6M - https://portal.u-blox.com/s/question/0D52p0000ArpeD7CQI/arduino-neo6m-basic-test
- no IDE Arduino library TinyGPS
## terça 14 de maio de 2025
Projeto Lousa-mágica http://abav.lugaralgum.com/lousa-magica
Código lousa-magica montagem 2 potenciômetros:
https://gist.github.com/villares/f575779c79ae8730347c0a566ad91752
Código árvore
https://gist.github.com/villares/8496a2270acbaa60b92d209ecc31a721
## Usando py5
- Referência https://abav.lugaralgum.com/material-aulas/Processing-Python-py5/sumario-referencia-py5.html

```python
def setup():
size(500, 500)
def draw():
d = random(10, 50)
fill(random(255), random(255), random(255))
if is_mouse_pressed:
circle(mouse_x, mouse_y, d)
```
Pincel "imported mode" (modo didático)
```python
def setup():
size(500, 500)
background(0) # fundo preto
color_mode(HSB) # matiz, sat, bri
no_stroke()
def draw():
d = 30
matiz = frame_count % 256
#print(matiz)
fill(matiz, 255, 255)
if is_mouse_pressed:
circle(mouse_x, mouse_y, d)
```
Pincel "module mode" (modo profisse)
```python
import py5
def setup():
py5.size(500, 500)
py5.background(0) # fundo preto
py5.color_mode(py5.HSB) # matiz, sat, bri
py5.no_stroke()
def draw():
d = 30
matiz = py5.frame_count % 256
#print(matiz)
py5.fill(matiz, 255, 255)
if py5.is_mouse_pressed:
py5.circle(py5.mouse_x, py5.mouse_y, d)
py5.run_sketch()
```
Thonny com py5:
https://abav.lugaralgum.com/como-instalar-py5/
## terça 07 de maio de 2025
- [Uma outra história do Arduino](https://arduinohistory.github.io/)
- [Slides de referência](https://drive.google.com/file/d/0B1vJ6aH--6MJZlZvT2lLcTB6cTg/view?usp=drive_link&resourcekey=0-cnycyMMi30WD7aBz7q845Q)
- Simulador de Arduino: https://wokwi.com/arduino
```arduino=
int led = 13;
int pot = A0;
void setup() { // put your setup code here, to run once:
pinMode(led, OUTPUT);
pinMode(pot, INPUT);
Serial.begin(9600);
}
void loop() { // put your main code here, to run repeatedly:
int valor = analogRead(pot); // 0 a 1023
digitalWrite(led, HIGH);
delay(valor);
digitalWrite(led, LOW);
delay(valor);
Serial.println(valor); // mostrar valor
}
```
```ino=
int rele = 8; //seleciona o pino de entrada para o potencionetro
void setup() {
pinMode(rele,OUTPUT);
Serial.begin(9600);
// put your setup code here, to run once:
}
SensorValue
void loop() {
int sensorValue=analogRead(A0);
if(sensorValue>600){
digitalWrite(rele,HIGH);
delay(1000);
digitalWrite(rele,LOW);
}else{
digitalWrite(rele,LOW);
}
Serial.printin(sensorValue);
delay(3000)
```