New Text Documenterwe
New Text Documenterwe
h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
int button = 10;
#define POTENTIOMETER_PIN A5
#include <EEPROM.h>
int value1 ;
int value2 ;
int value3 ;
float value4 ;
float value5 ;
float stepr ;
float stepl ;
int boot ;
const int TS_LEFT = 910, TS_RT = 169, TS_TOP = 900, TS_BOT = 180;
int n_new = 0 ;
int n_old = 0 ;
void setup(void)
{
Serial.begin(9600);
uint16_t ID = tft.readID();
Serial.print("TFT ID = 0x");
Serial.println(ID, HEX);
if (ID == 0xD3D3) ID = 0x9486; // write-only shield
pinMode(button, INPUT);
digitalWrite(button, HIGH); //activate arduino internal pull up
tft.begin(ID);
tft.setRotation(1); //PORTRAIT
tft.setTextSize(3);
tft.fillScreen(BLACK);
if (digitalRead(button)==LOW){
tft.setTextSize(2);
tft.setTextColor(WHITE, BLACK);
tft.setCursor(103,45);
tft.print("ELBAHLWAN DIGITAL RUDER");
tft.setTextColor(WHITE, RED);
tft.setCursor(170,75);
tft.print("Device Setup");
tft.drawCircle(100,240,65,WHITE);
tft.drawCircle(240,240,65,WHITE);
tft.drawCircle(380,240,65,WHITE);
////
tft.setTextSize(7);
tft.setTextColor(GREEN, BLACK);
tft.setCursor(340,215);
tft.print(">>");
}
int val = analogRead(POTENTIOMETER_PIN) ;
EEPROM.put(0, (val/5));
delay(1000);
tft.setTextColor(GREEN, BLACK);
tft.setCursor(365,140);
tft.print("OK");
////
tft.setTextSize(7);
tft.setTextColor(GREEN, BLACK);
tft.setCursor(225,215);
tft.print("0");
}
val = analogRead(POTENTIOMETER_PIN) ;
EEPROM.put(1, (val/5));
delay(1000);
tft.setTextColor(GREEN, BLACK);
tft.setCursor(227,140);
tft.print("OK");
////
tft.setTextSize(7);
tft.setTextColor(GREEN, BLACK);
tft.setCursor(60,215);
tft.print("<<");
for (int x=1; x<=20; x=x+1)
{
tft.setTextSize(3);
tft.setTextColor(WHITE, BLACK);
tft.setCursor(95,140);
tft.print(x);
delay(1000);
tft.setTextColor(BLACK, BLACK);
tft.setCursor(95,140);
tft.print(x);
Serial.println(analogRead(POTENTIOMETER_PIN));
}
val = analogRead(POTENTIOMETER_PIN) ;
EEPROM.put(2, (val/5));
delay(1000);
tft.setTextColor(GREEN, BLACK);
tft.setCursor(90,140);
tft.print("OK");
tft.fillScreen(BLACK);
tft.setTextColor(WHITE, BLACK);
tft.setCursor(240, 240);
tft.drawCircle(240,240,223,WHITE);
}
for (i=30; i<=120; i=i+0.4)
{
float angle = (i / 57.2958) - 1.57;
float x= 240 + cos(angle) * 220;
float y = 239+sin(angle) * 220;
tft.drawLine(240, 239,x,y, GREEN);
tft.fillCircle(240,239,195,BLACK);
tft.drawCircle(240,239,194,WHITE);
i=randomvalue;
for (i=-90; i<=90; i=i+2)
{
float angle = (i / 57.2958) - 1.57;
float x= 240 + cos(angle) * 194;
float y = 239+sin(angle) * 194;
tft.drawLine(240, 239,x,y, WHITE);
}
tft.fillCircle(240,239,190,BLACK);
i=randomvalue;
for (i=-90; i<=90; i=i+10)
{
float angle = (i / 57.2958) - 1.57;
float x= 240 + cos(angle) * 194;
float y = 239+sin(angle) * 194;
tft.drawLine(240, 239,x,y, WHITE);
}
tft.fillCircle(240,239,185,BLACK);
tft.setTextSize(2);
tft.setTextColor(GREEN, BLACK);
tft.setCursor(235,60);
tft.print("0");
tft.setCursor(290,68);
tft.print("10");
tft.setCursor(345,100);
tft.print("20");
tft.setCursor(378,142);
tft.print("30");
tft.setCursor(398,200);
tft.print("40");
tft.setCursor(165,68);
tft.print("10");
tft.setCursor(114,100);
tft.print("20");
tft.setCursor(81,142);
tft.print("30");
tft.setCursor(61,200);
tft.print("40");
tft.setTextSize(2);
tft.setTextColor(WHITE, BLACK);
tft.setCursor(103,280);
tft.print("ELBAHLWAN DIGITAL RUDER");
tft.setTextSize(2);
tft.setTextColor(WHITE, RED);
tft.setCursor(10,10);
tft.print("MUSTAFA");
value1 = 415;
value2 = 670;
value3 = 790;
void loop(void)
{
boot = analogRead(POTENTIOMETER_PIN) ;
Serial.println(boot);
if(n_new>90)
{
n_new=90;
}
if(n_new<-90)
{
n_new=-90;
}
Serial.println(n_new);
if(abs(n_new-n_old )> 2 )
{
if(abs(n_new-n_old )< 45)
{
}
delay(500);