blockBreaker/blockBreaker.ino

31 lines
655 B
C++

#include <Arduino.h>
#include <SPI.h> //for screen
#include <U8g2lib.h> //for screen
#include <stdlib.h>
#define ADC_PIN 26
int adcVal = 0;
float xLocation = 0;
//screen setup
U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R2, 17, 20, 21);
//uint8_t *buf;
char outString[99];
void setup() {
//setup screen
u8g2.begin();
u8g2.setFont(u8g2_font_ncenB14_tr);
//setup ADC
analogReadResolution(10);
digitalWriteFast(23, 1);
}
void loop() {
adcVal = analogRead(ADC_PIN);
xLocation = (((float)adcVal/1024)*100);
u8g2.clearBuffer();
sprintf(outString, "helloworld");
u8g2.drawStr(xLocation, 35, outString);
u8g2.sendBuffer();
}