https://drive.google.com/drive/folders/1UFMB3KF1HN9RfBB-cDqGFmip7AdfXqTZ?usp=sharing
https://studycadcam.blogspot.com/
https://images-na.ssl-images-amazon.com/images/I/91BLCCISDTL._SY355_.jpg
https://media.wired.com/photos/5a21eee60cb42c3d9653d08c/master/pass/r2d2-FA.jpg
https://github.com/RoboticsBrno/RoboticsBeginners2017-2018/tree/master/2018-03-20_lcd_i2c_display
https://github.com/marcoschwartz/LiquidCrystal_I2C
https://github.com/RoboticsBrno/RoboticsBeginners2017-2018/
DHT11 knihovna:
https://github.com/adafruit/DHT-sensor-library
Posli te mi vas email na muj email:
paral@robotikabrno.cz
Předmět: [Robotika Začátečníci 2017] VASE JMENO - VAS EMIAL
To samé dejte do předmětu zprávy.
https://github.com/RoboticsBrno/RoboticsBeginners2017-2018/
https://github.com/RoboticsBrno/RoboticsBeginners2017-2018/blob/master/2017-11-07_test-board/src/main.cpp
#include "LearningKit.h"
#include <SPIFFS.h>
#include <DHT.h>
DHT dht( DHT_PIN, DHT11 );
#include "Servo.h"
Servo servo1;
#define I2C_SDA 27
#define I2C_SCL 14
// Uncomment your type of LCD convertor
//#define LCD_I2C_ADDR 0x27 // chip PCF8574T
#define LCD_I2C_ADDR 0x3f // chip PCF8574AT
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_WIDTH, LCD_HEIGHT);
int hour, min, sec;
void incrementClockSec()
{
sec = sec + 1;
if(sec == 60) {
//min = min + 1;
min += 1;
sec = 0;
}
if(min == 60) {
//hour = hour + 1;
hour++;
min = 0;
}
if(hour == 24) {
hour = 0;
}
}
void setup()
{
setupLeds();
setupRgbLed();
setupButtons();
Serial.begin(115200);
Serial.println("Logging - start");
SPIFFS.begin();
dht.begin();
servo1.attach(S1);
Wire.begin(I2C_SDA, I2C_SCL);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.backlight();
lcd.print("ahoj");
hour = 9;
min = 25;
sec = 50;
File file = SPIFFS.open("/log.txt", FILE_APPEND);
if (!file) {
Serial.println("Failed to open file for appending");
return;
}
int state = true;
while(digitalRead(SW1) == true) {
int timeMs = millis();
int photoVal = analogRead(PHOTO);
int dhtTemp = dht.readTemperature();
int dhtHum = dht.readHumidity();
file.print( timeMs );
file.print( "; " );
file.print( photoVal );
file.print( "; " );
file.print( dhtTemp );
file.print( "; " );
file.print( dhtHum );
file.print( "\n" );
Serial.printf("%i; %i; %i; %i\n", timeMs, photoVal, dhtTemp, dhtHum);
int servoPos = map(int(dht.readTemperature()), 0, 40, 0, 180);
servo1.write(servoPos);
lcd.setCursor(1, 1);
lcd.printf("%iC %i", dhtTemp, dhtHum);
lcd.print("%");
lcd.setCursor(0, 0);
lcd.printf("Time: %2i:%02i:%02i", hour, min, sec);
incrementClockSec();
delay(1000);
if(state == true)
state = false;
else
state = true;
digitalWrite(L_R, state);
}
file.close();
digitalWrite(L_R, LOW);
digitalWrite(L_G, HIGH);
Serial.println("Logging - stop");
file = SPIFFS.open("/log.txt");
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
Serial.println("Logging - read");
while (file.available())
{
Serial.write(file.read());
}
file.close();
}
void loop()
{
}
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
1745
DHT sensor library
https://github.com/copercini/arduino-esp32-SPIFFS
ServoESP32
https://github.com/marcoschwartz/LiquidCrystal_I2C.git
monitor_baud = 115200
upload_speed = 921600
#include "LearningKit.h"
#include <SPIFFS.h>
#include <DHT.h>
DHT dht( DHT_PIN, DHT11 );
#include "Servo.h"
Servo servo1;
#define I2C_SDA 27
#define I2C_SCL 14
// Uncomment your type of LCD convertor
//#define LCD_I2C_ADDR 0x27 // chip PCF8574T
#define LCD_I2C_ADDR 0x3f // chip PCF8574AT
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_WIDTH, LCD_HEIGHT);
int hour, min, sec;
void incrementClockSec()
{
sec = sec + 1;
delay(1000);
if(sec == 60) {
//min = min + 1;
min += 1;
sec = 0;
}
if(min == 60) {
//hour = hour + 1;
hour++;
min = 0;
}
if(hour == 24) {
hour = 0;
}
}
void setup()
{
setupLeds();
setupRgbLed();
setupButtons();
Serial.begin(115200);
Serial.println("Logging - start");
SPIFFS.begin();
dht.begin();
servo1.attach(S1);
Wire.begin(I2C_SDA, I2C_SCL);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.backlight();
lcd.print("ahoj");
hour = 9;
min = 25;
sec = 50;
File file = SPIFFS.open("/log.txt", FILE_APPEND);
if (!file) {
Serial.println("Failed to open file for appending");
return;
}
while(digitalRead(SW1) == true) {
int timeMs = millis();
int photoVal = analogRead(PHOTO);
int dhtTemp = dht.readTemperature();
int dhtHum = dht.readHumidity();
file.print( timeMs );
file.print( "; " );
file.print( photoVal );
file.print( "; " );
file.print( dhtTemp );
file.print( "; " );
file.print( dhtHum );
file.print( "\n" );
Serial.printf("%i; %i; %i; %i\n", timeMs, photoVal, dhtTemp, dhtHum);
int servoPos = map(int(dht.readTemperature()), 0, 40, 0, 180);
servo1.write(servoPos);
lcd.setCursor(1, 1);
lcd.printf("%iC %i", dhtTemp, dhtHum);
lcd.print("%");
lcd.setCursor(0, 0);
lcd.printf("Time: %2i:%02i:%02i", hour, min, sec);
incrementClockSec();
delay(1000);
}
file.close();
Serial.println("Logging - stop");
file = SPIFFS.open("/log.txt");
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
Serial.println("Logging - read");
while (file.available())
{
Serial.write(file.read());
}
file.close();
}
void loop()
{
}
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_baud = 115200
upload_speed = 921600
lib_deps =
1745
ServoESP32
// source: http://platformio.org/lib/show/1739/ServoESP32
#include "LearningKit.h"
#include <Servo.h>
static const int servoPin = S1;
static const int potentiometerPin = 32;
Servo servo1;
void setup() {
Serial.begin(115200);
servo1.attach(servoPin);
}
void loop() {
int servoPosition = map(analogRead(potentiometerPin), 0, 4096, 0, 180);
servo1.write(servoPosition);
Serial.println(servoPosition);
delay(20);
}
#define I2C_SDA 23
#define I2C_SCL 22
#define LCD_I2C_ADDR 0x3f
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#include <Arduino.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(LCD_I2C_ADDR, LCD_WIDTH, LCD_HEIGHT);
void setup() {
Serial.begin(115200);
Serial.println("\n\n\nI2C LCD display test");
Wire.begin(I2C_SDA, I2C_SCL);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.backlight();
lcd.print("ahoj");
Serial.print("ahoj\n");
}
int receiveCh;
void loop() {
if (Serial.available()) {
receiveCh = Serial.read();
lcd.write(receiveCh);
Serial.write(receiveCh);
}
}
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_baud = 115200
upload_speed = 921600
build_flags = -D CORE_INT_EVERY_PIN
lib_deps =
https://github.com/marcoschwartz/LiquidCrystal_I2C.git
#include "LearningKit.h"
#include <SPIFFS.h>
void setup()
{
setupButtons();
Serial.begin(115200);
Serial.println("Logging - start");
SPIFFS.begin();
File file = SPIFFS.open("/log.txt", FILE_WRITE);
if (!file)
{
Serial.println("Failed to open file for appending");
return;
}
while(digitalRead(SW1) == true) {
file.println(analogRead(PHOTO));
Serial.printf("data: %i\n", analogRead(PHOTO));
delay(100);
}
file.close();
Serial.println("Logging - stop");
file = SPIFFS.open("/log.txt");
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
Serial.println("Logging - read");
while (file.available())
{
Serial.write(file.read());
}
file.close();
}
void loop()
{
}
#include "LearningKit.h"
#include <DHT.h>
DHT dht( DHT_PIN, DHT11 );
void setup() {
Serial.begin(115200);
dht.begin();
}
void loop() {
Serial.print( "Temperature: " );
Serial.print( dht.readTemperature() );
Serial.print( "°C, humidity: " );
Serial.print( dht.readHumidity() );
Serial.println( " %\n" );
delay( 200 );
}
#include "LearningKit.h"
void setup() {
Serial.begin(115200);
setupRgbLed();
setupLeds();
setupButtons();
ledcSetup(1, 1000, 10); // ledcSetup(channel, freq, resolution)
// resolution = 10 => 2^10 => 1024
ledcAttachPin(L_RGB_R, 1);
}
int state = 1; // 1 = up, -1 = down
//bool state = 1; // 1 = up, 0 = down
int light = 0;
void loop() {
light += state;
//for(/*inicializace/*; /*podmínka*/; /*aktualizace řídící proměnné */)
for(int i = 0; i < 1023; i++) {
ledcWrite(1, i);
delay(1);
}
ledcWrite(1, light); // ledcWrite(channel, value)
// value => resolution = 1024 => value = 0 - 1023
delay(1);
}
#include "LearningKit.h"
void setup() {
Serial.begin(115200);
setupRgbLed();
setupLeds();
setupButtons();
ledcSetup(1, 1000, 10); // ledcSetup(channel, freq, resolution)
// resolution = 10 => 2^10 => 1024
ledcAttachPin(L_G, 1);
}
int state = 1; // 1 = up, -1 = down
//bool state = 1; // 1 = up, 0 = down
int light = 0;
void loop() {
light += state;
if(light == 0) {
state = +1;
}
if(light == 1023) {
state = -1;
}
ledcWrite(1, light); // ledcWrite(channel, value)
// value => resolution = 1024 => value = 0 - 1023
delay(1);
}
#include "LearningKit.h"
int hour, min, sec;
bool alarm = false;
void setup() {
Serial.begin(115200);
setupLeds();
setupRgbLed();
setupButtons();
hour = 17;
min = 29;
sec = 50;
}
void loop() {
sec = sec + 1;
delay(1000);
if(sec == 60) {
//min = min + 1;
min += 1;
sec = 0;
}
if(min == 60) {
//hour = hour + 1;
hour++;
min = 0;
}
if(hour == 24) {
hour = 0;
}
if(digitalRead(SW1) == false) {
alarm = false;
}
if((hour == 17) && (min == 30) && (sec == 0)) {
alarm = true;
}
if(alarm == true) {
digitalWrite(L_R, HIGH);
} else {
digitalWrite(L_R, LOW);
}
Serial.printf("%2i:%02i:%02i\n", hour, min, sec);
}
#include "LearningKit.h"
int hour, min, sec;
void setup() {
Serial.begin(115200);
setupLeds();
setupRgbLed();
hour = 17;
min = 29;
sec = 0;
}
void loop() {
sec = sec + 1;
delay(1000);
if(sec == 60) {
//min = min + 1;
min += 1;
sec = 0;
}
if(min == 60) {
//hour = hour + 1;
hour++;
min = 0;
}
if(hour == 24) {
hour = 0;
}
// Serial.print(hour);
// Serial.print(":");
// Serial.print(min);
// Serial.print(":");
// Serial.println(sec);
Serial.printf("%2i:%02i:%02i\n", hour, min, sec);
if((hour == 17) && (min == 30)) {
digitalWrite(L_R, HIGH);
} else {
digitalWrite(L_R, LOW);
}
}
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps =
1745
https://github.com/copercini/arduino-esp32-SPIFFS.git
monitor_baud = 115200
#include <SPIFFS.h>
void setup()
{
Serial.begin(115200);
SPIFFS.begin();
File file = SPIFFS.open("/log.txt", FILE_WRITE);
file.println(42);
file.close();
file = SPIFFS.open("/log.txt");
while (file.available()) {
Serial.write(file.read());
}
file.close();
}
void loop() {
}