- MIUI / HyperOS topik
- iPhone topik
- Fotók, videók mobillal
- Szonárral ad ultimátumot a Huawei az órapiacnak
- Tesztpadon a One UI 8.5
- Apple Watch Sport - ez is csak egy okosóra
- Milyen okostelefont vegyek?
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Be is futott a Samsung új olcsó mobilja
- Google Pixel 8 Pro - mestersége(s) az intelligencia
-
Mobilarena
Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.
Új hozzászólás Aktív témák
-
lanszelot
addikt
válasz
its_grandpa #20046 üzenetére
Beírtam a kódot, és nem működik.
Mivel sok hiba volt benne, és azokat javítottam, valószínű valamit nem jól csináltam.
Arra viszont még nem jöttem rá mit.kód jelenleg:
#include <MQ135.h> /*gaz erzekelo, de nem kell neki igazabol*/
#include <Adafruit_SSD1306.h> /*oled display*/
#include <splash.h> /*oled display -nek kell*/
#include <max6675.h> /*homero*/
int thermoDO = 10; /*valtozo a homero DO pin -nek*/
int thermoCS = 9; /*valtozo a homero CS pin -nek*/
int thermoCLK = 8; /*valtozo a homero CLK pin -nek*/
//int gombPin = 4; /*valtozo a gomb pin -nek*/
int gombAllapot = 0; /*valtozo a gomb allapot olvasasahoz*/
byte a = 0; /*valtozo a gaz erzekelo negyzet villogashoz*/
int period = 1000; /*ennyi idot var a futtatashoz*/
unsigned long time_now = 0;
const int ledPin = 6; /*LED pin*/
const byte interruptPin = 4;
volatile int gombNyomas = 0 ; /*valtozo a gomb nyomas szamlalasara*/
uint32_t lastms= 0;
void gombotnyom(){
gombNyomas ++; /* növeljük 1-el a gombnyomások számát */
}
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
Adafruit_SSD1306 display = Adafruit_SSD1306(128, 64, &Wire);
void mindenRajtaVan() {
int sensorValue = analogRead(A0); /*valtozo a gaz erzekelo alalog pin -nek*/
int isgas = digitalRead(2); /*valtozo a gaz erzekelo digitalis pin -nek, ez arra kell, ha gas van akkor jelet ad, nem kell kulon erteket adni*/
String gas; /*valtozo a gaz erzekelo gas vagy no gas kiirasahoz*/
display.clearDisplay(); /*this line to clear previous logo*/
display.setTextSize(1); /*text size 3*/
display.setCursor(3,0); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("Thermometer by Gabor");
display.setTextSize(2); /*text size 2*/
display.setCursor(10,20); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("C = ");
display.print(thermocouple.readCelsius());/*Celsius*/
display.setTextSize(1); /*text size 2*/
display.setCursor(10,40); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("F = ");
display.print(thermocouple.readFahrenheit());/*Fahrenheit*/
display.setTextSize(1); /*text size 2*/
display.setCursor(0,50); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("CO2 = ");
display.print(sensorValue);
display.print(" PPM ");
/*sensorValue < 90 ellenorzeshez, amugy igas valtozo kell ami a digitalis pin*/
if (sensorValue < 90) {gas = "No Gas";}
else {gas = " Gas";
if(a) {display.drawRoundRect(80, 47, 40, 15, 2, WHITE);/*negyzet a gas felirat kore feher*/
digitalWrite(ledPin, HIGH);} /*LED bekapcsol*/
else {display.drawRoundRect(80, 47, 40, 15, 2, BLACK); /*negyzet a gas felirat kore fekete*/
digitalWrite(ledPin, LOW);} /*LED kikapcsol*/
a^=1;
}
display.print(gas);
display.display(); /*to shows or update your TEXT*/
}
void homeroVanRajta() {
digitalWrite(ledPin, LOW); /*LED kikapcsol*/
display.clearDisplay(); /*this line to clear previous logo*/
display.setTextSize(1); /*text size 3*/
display.setCursor(3,0); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("Thermometer by Gabor");
display.setTextSize(2); /*text size 2*/
display.setCursor(10,20); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("C = ");
display.print(thermocouple.readCelsius());/*Celsius*/
display.setTextSize(2); /*text size 2*/
display.setCursor(10,40); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("F = ");
display.print(thermocouple.readFahrenheit());/*Fahrenheit*/
display.display(); /*to shows or update your TEXT*/
}
void gazVanRajta() {
int sensorValue = analogRead(A0); /*valtozo a gaz erzekelo alalog pin -nek*/
int isgas = digitalRead(2); /*valtozo a gaz erzekelo digitalis pin -nek, ez arra kell, ha gas van akkor jelet ad, nem kell kulon erteket adni*/
String gas; /*valtozo a gaz erzekelo gas vagy no gas kiirasahoz*/
display.clearDisplay(); /*this line to clear previous logo*/
display.setTextSize(1); /*text size 3*/
display.setCursor(3,0); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("Thermometer by Gabor");
display.setTextSize(2); /*text size 2*/
display.setCursor(0,20); /*ez tartja egy helyben a szöveget*/
display.setTextColor(WHITE); /*without this no display*/
display.print("CO2= ");
display.print(sensorValue);
display.setTextSize(1);
display.print(" PPM");
/*sensorValue < 90 ellenorzeshez, amugy igas valtozo kell ami a digitalis pin*/
if (sensorValue < 90) {gas = "No Gas";}
else {gas = " Gas";
if(a) {display.drawRoundRect(30, 39, 60, 22, 2, WHITE);/*negyzet a gas felirat kore feher*/
digitalWrite(ledPin, HIGH);} /*LED bekapcsol*/
else {display.drawRoundRect(30, 39, 60, 22, 2, BLACK); /*negyzet a gas felirat kore fekete*/
digitalWrite(ledPin, LOW);} /*LED kikapcsol*/
a^=1;
}
display.setTextSize(2);
display.setCursor(20,42);
display.print(gas);
display.display(); /*to shows or update your TEXT*/
}
void megnyomva() {
switch (gombNyomas) {
case 1:
mindenRajtaVan();
break;
case 2:
homeroVanRajta();
break;
case 3:
gazVanRajta();
break;
}
} /* megnyomva_end */
void setup() {
Serial.begin(9600); /*elindítja a sorosportot, 9600 baud beállítással. Ez azért jó, mert a Serial Monitoron a program futását tudod monitorozni*/
pinMode(ledPin, OUTPUT); /*inicializálja a LED pin -jet outputnak*/
pinMode(interruptPin, INPUT_PULLUP); /*inicializálja a gomb pin-t inputnak , default HIGH !!! */
attachInterrupt(digitalPinToInterrupt(interruptPin), gombotnyom, LOW); /* meghívjuk az fv.-t ha LOW-ra húzod a pin-t */
Serial.println("MAX6675 test");
/*wait for MAX chip to stabilize*/
delay(500);
/*SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally*/
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); /*Address 0x3C for 128x32*/
display.display();
delay(2000);
}
void loop() {
if (millis() - lastms > 10000) /* eltelt 10 sec ? */
{
lastms = millis();
if (gombNyomas > 0) /* volt valamennyi gombnyomás */
{
megnyomva();
gombNyomas = 0 ; /* nullázzuk a nyomások számát
}
} /* gombnyomások számának olvasás időzítése */
Serial.println(gombNyomas); /* kiírjuk hány gombnyomásnál tartasz */
} /* loop_end */
/*Jöjjön a megnyomva fv.*/
}
}egy hibát már meg is találtam:
volatile int gombNyomas = 1 ;
1-nek kell lenni, mert semmi se fut le induláskor.
Most már mutatja a kijelző, de azonnal kifagy
Új hozzászólás Aktív témák
- BESZÁMÍTÁS! 16GB (2x8) Kingston HyperX Fury 1600MHz DDR3 memória garanciával hibátlan működéssel
- BESZÁMÍTÁS! 16GB (2x8) Kingston HyperX Fury 1333MHz DDR3 memória garanciával hibátlan működéssel
- BESZÁMÍTÁS! 32GB (2x16) G.Skill Ripjaws V 4000MHz DDR4 memória garanciával hibátlan működéssel
- BESZÁMÍTÁS! 64GB (2x32) Samsung 3200MHz DDR4 memória garanciával hibátlan működéssel
- BESZÁMÍTÁS! 64GB (2x32) Kingston HyperX Renegade 2666MHz DDR4 garanciával hibátlan működéssel
- Bomba ár! Lenovo ThinkPad T460 - i5-6GEN I 8GB I 256GB SSD I 14" FHD I Cam I W10 I Garancia!
- ÁRGARANCIA!Épített KomPhone i7 14700KF 32/64GB RAM RTX 5070 Ti 16GB GAMER PC termékbeszámítással
- Samsung Galaxy A55 5G / 8RAM 256GB / Gyárifüggetlen / 12 Hó Garanciával
- GYÖNYÖRŰ iPhone 13 mini 128GB Green -1 ÉV GARANCIA - Kártyafüggetlen, MS3338
- Bomba ár! HP ProBook 645 G1 - AMD A6-5350M I 8GB I 500GB I 14" HD I Cam I W10 I Garancia!
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest