Arama butonu
Bu konudaki kullanıcılar: 1 misafir
4
Cevap
1132
Tıklama
0
Öne Çıkarma
1 Arduino İle 2 Farklı Görev Yaptırma (Koda Müdahale Edebilir Misiniz ?
M
4 yıl
Yarbay
Konu Sahibi

Selamlar,

Arduino ile buton üzerinden buzzer çalıştırıyorum. Aynı zamanda farklı bir Arduinodan Lcd ekrana sıcaklık sensörü verisini yazdırıyordum. Fakat bu iki görevi tek bir arduino kartı ile yaptırmam gerekiyor. Lütfen kodlarıma gerekli müdahaleyi nasıl yapabilceğimi tarif edebilri misiniz ?



#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

const int sensorPin = A0;
float sensorValue;
float voltageOut;

float temperatureC;

// uncomment if using LM335
//float temperatureK;
const int buttonPin = 3;   // the number of the pushbutton pin
int Buzzer1 = 11;

// variables will change:
int buttonState = 0;     // variable for reading the pushbutton status

void setup() {
 pinMode(sensorPin, INPUT);
 Serial.begin(9600);

 if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
  Serial.println(F("SSD1306 allocation failed"));
  for (;;);
 }

 delay(2000);
 display.clearDisplay();
 display.setTextColor(WHITE);
 // initialize the piezo as output:
 pinMode(Buzzer1, OUTPUT);
 // initialize the pushbutton pin as an input:
 pinMode(buttonPin, INPUT);
}



void loop() {
 sensorValue = analogRead(sensorPin);
 voltageOut = (sensorValue * 5000) / 1024;

 // calculate temperature for LM35 (LM35DZ)
 temperatureC = voltageOut / 10;

 // calculate temperature for LM335
 //temperatureK = voltageOut / 10;
 //temperatureC = temperatureK - 273;
 //temperatureF = (temperatureC * 1.8) + 32;

 // calculate temperature for LM34
 //temperatureF = voltageOut / 10;
 //temperatureC = (temperatureF - 32.0)*(5.0/9.0);

 Serial.print("MOTOR SICAKLIK(ºC): ");
 Serial.print(temperatureC);
 Serial.print("ERHAN DEMIR 2021");


 // clear display
 display.clearDisplay();

 // display temperature Celsius
 display.setTextSize(1);
 display.setCursor(0, 0);
 display.print("MOTOR SICAKLIGI: ");
 display.setTextSize(2);
 display.setCursor(0, 10);
 display.print(temperatureC);
 display.print(" ");
 display.setTextSize(1);
 display.cp437(true);
 display.write(167);
 display.setTextSize(2);
 display.print("C");

 // display temperature Fahrenheit
 display.setTextSize(2);
 display.setCursor(0, 35);
 display.print("Erhan   Demir 2021 ");
 display.setTextSize(2);
 display.setCursor(0, 45);


 display.display();
 delay(1000);

 // read the state of the pushbutton value:
 buttonState = digitalRead(buttonPin);

 if (buttonState == HIGH) {
  // play th Music
  tone(Buzzer1, 194, 200);
  delay(40);
  tone(Buzzer1, 94, 40);
  delay(40);
 }
}

DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.

Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.

Üye Ol Şimdi Değil



A
4 yıl
Teğmen

Şu bağlantıdan yardım alabilirsin;

https://googledaariyim.com/?q=Arduino+assembly+dersleri



< Bu ileti iOS uygulamasından atıldı >
Bu mesaja 1 cevap geldi.
DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.