ReflowController/Software/sketch_hardware_test/sketch_hardware_test.ino

56 lines
1,003 B
Arduino
Raw Normal View History

2020-06-06 18:26:48 +02:00
#include <Arduino.h>
#include <U8g2lib.h>
#include <Encoder.h>
2020-06-06 18:26:48 +02:00
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 10, /* reset=*/ 8);
Encoder rotEncoder(2, 3);
2020-06-06 18:26:48 +02:00
2020-06-06 20:00:45 +02:00
const int buzzer = 5;
void setup(void) {
Serial.begin(9600);
Serial.println("Hardware Test:");
2020-06-06 18:26:48 +02:00
2020-06-06 20:00:45 +02:00
pinMode(buzzer, OUTPUT);
2020-06-06 18:26:48 +02:00
u8g2.begin();
2020-06-06 20:00:45 +02:00
Serial.println("Buzzer Test");
tone(buzzer, 1000, 5000);
Serial.println("Buzzer Test");
delay(1000);
Serial.println("Buzzer Test 2");
delay(1000);
Serial.println("Buzzer Test 3");
}
2020-06-06 18:26:48 +02:00
long EncPos = 0;
2020-06-06 18:26:48 +02:00
void loop(void) {
long newEncPos;
newEncPos = rotEncoder.read();
if (newEncPos != EncPos) {
Serial.print("Encoder position = ");
Serial.print(newEncPos);
Serial.println();
EncPos = newEncPos;
}
2020-06-06 18:26:48 +02:00
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB10_tr);
u8g2.drawStr(0,24,"Hello World!");
} while ( u8g2.nextPage() );
//delay(1000);
}