//current programm for WAVE blaster (should blast >100Watt pulsed up to 400kHz over 3 ceramic water fog piezos **acxutelly try to find correct coil dimensions for drivingvoltage) also powerbank , RGB lamp, WIFI TCP terminal .. primary anti-dog thingi) //meow its free use it or parts if usefull :3 (working butn not finished now) #include #include #include #include //open this file to see possible functions // /\/\replace path to zip unzip directory (also in other ccp and h files in folder) //connect display to SCL: PB6 -- SDA: PB7 -- VCC: 5V (3.3V also works) -- GND: G #define powerx PB12 #define kan PB13 #define rot PB14 #define grun PB15 #define blau PA8 #define t1 PA9 #define t2 PA10 #define t3 PA12 #define t4 PA15 #define t5 PB5 #define tpower PA1 #define battopto PA0 #define weisnicht1 PC13 //purr maybe some 0603 leds in casematerial #define weisnicht2 PC14 #define weisnicht3 PC15 #define weisnicht4 PA2 #define weisnicht5 PA3 #define weisnicht6 PA4 #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); const unsigned char PROGMEM cat [] = // width 66px height 46 { 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, // ## 0x00, 0x00, 0x0F, 0x0E, 0x18, 0x60, 0x00, 0x00, 0x00, // #### ### ## ## 0x00, 0x00, 0x04, 0x94, 0xF9, 0xE0, 0x00, 0x00, 0x00, // # # # # ##### #### 0x00, 0x00, 0x02, 0x67, 0xB7, 0x40, 0x00, 0x00, 0x00, // # ## #### ## ### # 0x00, 0x3F, 0xFC, 0x22, 0x26, 0x40, 0x00, 0x00, 0x00, // ############ # # # ## # 0x01, 0xE0, 0x04, 0x62, 0x2C, 0x60, 0x00, 0x00, 0x00, // #### # ## # # ## ## 0x07, 0x00, 0x00, 0x02, 0x38, 0x3F, 0xF8, 0x00, 0x00, // ### # ### ########### 0x3C, 0x00, 0x00, 0x02, 0x10, 0x00, 0x0F, 0x80, 0x00, // #### # # ##### 0x60, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, // ## ##### #### 0xDF, 0xE0, 0x7F, 0xE0, 0x01, 0xFE, 0x00, 0x1C, 0x00, // ## ######## ########## ######## ### 0xF0, 0x30, 0xFF, 0xF0, 0x07, 0xFF, 0x00, 0x07, 0x00, // #### ## ############ ########### ### 0x80, 0x18, 0xFF, 0xF0, 0x0F, 0xFF, 0x00, 0x01, 0x80, // # ## ############ ############ ## 0xC0, 0x31, 0xFF, 0xF8, 0x1F, 0xFF, 0x83, 0xFC, 0xC0, // ## ## ############## ############## ######## ## 0x41, 0x19, 0xFF, 0xF8, 0x1F, 0xFF, 0x82, 0x07, 0xC0, // # # ## ############## ############## # ##### 0x61, 0xF1, 0xFF, 0xF8, 0x1F, 0xFF, 0xCE, 0x00, 0x40, // ## ##### ############## ############### ### # 0x20, 0x81, 0xFF, 0xFC, 0x1F, 0xFF, 0xC7, 0xC0, 0x40, // # # ############### ############### ##### # 0x30, 0x71, 0xFF, 0xFC, 0x3F, 0xFF, 0xC0, 0x40, 0xC0, // ## ### ############### ################ # ## 0x10, 0x39, 0x3F, 0xE4, 0x3F, 0xFF, 0xC1, 0x80, 0x80, // # ### # ######### # ################ ## # 0x18, 0x41, 0x00, 0x04, 0x3F, 0xFE, 0x66, 0x00, 0x80, // ## # # # ############# ## ## # 0x0E, 0x01, 0xFF, 0xE4, 0x3F, 0xF0, 0x23, 0x01, 0x80, // ### ############ # ########## # ## ## 0x03, 0x01, 0xC0, 0x3C, 0x20, 0x00, 0x20, 0x03, 0x00, // ## ### #### # # ## 0x01, 0x81, 0x00, 0x08, 0x3F, 0x00, 0x20, 0x02, 0x00, // ## # # ###### # # 0x00, 0x80, 0x00, 0x00, 0x31, 0xFE, 0x60, 0x06, 0x00, // # ## ######## ## ## 0x00, 0xC0, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x0C, 0x00, // ## #### ## 0x00, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0xC0, 0x18, 0x00, // ### ####### ## ## 0x00, 0x1C, 0x38, 0x11, 0xE7, 0xF0, 0x00, 0x30, 0x00, // ### ### # #### ####### ## 0x00, 0x04, 0x60, 0xF1, 0xC3, 0x9C, 0x00, 0x60, 0x00, // # ## #### ### ### ### ## 0x00, 0x0C, 0xC1, 0x80, 0x80, 0xC6, 0x40, 0xC0, 0x00, // ## ## ## # ## ## # ## 0x00, 0x10, 0x83, 0x00, 0x00, 0x60, 0x67, 0x80, 0x00, // # # ## ## ## #### 0x00, 0xE0, 0x06, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, // ### ## #### 0x01, 0x80, 0x04, 0x00, 0x80, 0x80, 0x30, 0x00, 0x00, // ## # # # ## 0x00, 0xFF, 0x80, 0x20, 0x81, 0xF0, 0x0E, 0x00, 0x00, // ######### # # ##### ### 0x00, 0x18, 0x60, 0x11, 0xC6, 0x18, 0x03, 0xC0, 0x00, // ## ## # ### ## ## #### 0x00, 0x60, 0x00, 0x1F, 0x7C, 0x0C, 0x3C, 0x60, 0x00, // ## ##### ##### ## #### ## 0x00, 0x7F, 0x80, 0x14, 0x28, 0x04, 0x07, 0xC0, 0x00, // ######## # # # # # ##### 0x00, 0x43, 0xF0, 0x18, 0x1E, 0x34, 0x01, 0x00, 0x00, // # ###### ## #### ## # # 0x00, 0x02, 0x1C, 0x00, 0x02, 0x1C, 0x3D, 0x00, 0x00, // # ### # ### #### # 0x00, 0x06, 0x00, 0x00, 0x03, 0x10, 0x67, 0x80, 0x00, // ## ## # ## #### 0x00, 0x01, 0xC0, 0x00, 0x01, 0xB0, 0x34, 0x00, 0x00, // ### ## ## ## # 0x00, 0x00, 0x78, 0x00, 0x00, 0xE7, 0xF8, 0x00, 0x00, // #### ### ######## 0x00, 0x00, 0x0E, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, // ### ### 0x00, 0x00, 0x03, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, // ## # 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, // # # 0x00, 0x00, 0x01, 0x80, 0x00, 0x60, 0x00, 0x00, 0x00, // ## ## 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, // # # 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, // # # }; //use dotfactory to convert picture to array uint8_t onpress[12]; uint8_t zeit1; long ticktack=micros(); uint16_t speedy=0; uint16_t fuel=400; uint8_t dutys[20]; uint16_t RGB; uint16_t light,bright,darkness,battpower; void setup() { pinMode(rot, OUTPUT); pinMode(grun, OUTPUT); pinMode(blau, OUTPUT); pinMode(kan, OUTPUT); // pinMode(weis2, OUTPUT); pinMode(weis3, OUTPUT); pinMode(weisnicht1, OUTPUT); pinMode(weisnicht2, OUTPUT); pinMode(weisnicht3, OUTPUT); pinMode(weisnicht4, OUTPUT); pinMode(weisnicht5, OUTPUT); pinMode(weisnicht6, OUTPUT); pinMode(powerx, OUTPUT); pinMode(t1, INPUT); pinMode(t2, INPUT); pinMode(t3, INPUT); pinMode(t4, INPUT); pinMode(t5, INPUT); pinMode(tpower, INPUT); delay(350); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64) display.clearDisplay(); display.drawBitmap(10, 15,cat,66, 46, WHITE); display.display(); delay(350); Serial3.begin(115200);//Wifi } boolean confed=false; String wifistati=""; String irgentwas="";int cachs,lang,neuda; void loop() { display.clearDisplay(); istserial(); timehappend(); configwifi(); steptry(); buttons(); akkugeladen(); if (confed==true) {wifistati="";lang=0;irgentwas=""; display.setCursor(0,32); display.setTextSize(1); display.println(wifistati); machCATZ(); OLEDzeugs(); display.drawFastHLine(0,63,battpower/40, WHITE);} display.display(); } String cachb2=""; int speedb,speedso; void configwifi(void){ if ((speedb%2) == 1 && speedb <=10){digitalWrite(rot, LOW);} if ((speedb%2) == 0 && speedb <=10){digitalWrite(rot, HIGH);} if (speedso > 50) { if (speedb <13) { speedb++;} if (speedb ==1) { cachb2=""; Serial3.println("AT");} if (speedb ==2) { cachb2=""; Serial3.println("AT+RST"); wifistati = "START wifi conf.";} if (speedb ==3) { cachb2=""; Serial3.println("AT+CWLAP"); } if (speedb ==4) { cachb2=""; Serial3.println("AT+GMR");} if (speedb ==5) { cachb2=""; Serial3.println("AT+CWMODE=3"); wifistati = "LOAD.. meow! ";} if (speedb ==6) { cachb2=""; Serial3.println("AT+CWJAP=\"Acme-Labs2\",\"axruntpv\""); wifistati="connefting Acme-Labs";} if (speedb ==7) { cachb2=""; Serial3.println("AT+CIFT"); } if (speedb ==8) { cachb2=""; Serial3.println("AT+CIPMUX=1");wifistati = "purrr Wifi connected ";} if (speedb ==9) { cachb2=""; Serial3.println("AT+CIPSERVER=1,3366"); } if (speedb ==12) { wifistati = "READY... meow "; cachb2=""; digitalWrite(rot, LOW); digitalWrite(blau, LOW); Serial3.println("."); int kaaa=0; confed=true;} speedso=0; }} void akkugeladen(){ if (analogRead(battopto) < battpower) {battpower--;} if (analogRead(battopto) > battpower) {battpower++;} } void buttons() { // for reading tasters without clipping multiple count on one press effect if (zeit1 >=1) { if (digitalRead(t1) == HIGH && onpress[0] ==0) { onpress[0] =1; fuel+=10;} if (onpress[0] == 1) { onpress[1]++; digitalWrite(blau,HIGH);} if (onpress[1] >= 10) { onpress[1] =0; onpress[0]=0; } if (digitalRead(t2) == HIGH && onpress[2] ==0) { onpress[2] =1; } if (onpress[2] == 1) { onpress[3]++;digitalWrite(rot,HIGH); } if (onpress[3] >= 10) { onpress[3] =0; onpress[2]=0; } if (digitalRead(t3) == HIGH && onpress[4] ==0) { onpress[4] =1; } if (onpress[4] == 1) { onpress[5]++; } if (onpress[5] >= 10) { onpress[5] =0; onpress[4]=0; } if (digitalRead(t4) == HIGH && onpress[6] ==0) { onpress[6] =1; } if (onpress[6] == 1) { onpress[7]++; } if (onpress[7] >= 10) { onpress[7] =0; onpress[6]=0; } if (digitalRead(t5) == HIGH && onpress[8] ==0) { onpress[8] =1; } if (onpress[8] == 1) { onpress[9]++; } if (onpress[9] >= 10) { onpress[9] =0; onpress[8]=0; if (fuel >=10) {fuel-=10;}} zeit1=0; }} long clockthing=millis(); long itstime=millis(); long eventime=micros(); void timehappend(void) { while ((millis()- clockthing) >= 20) { zeit1++; speedso++; akkugeladen(); clockthing = millis(); } while ((micros()- itstime) >= 50) { // display.display();display.clearDisplay();// display.fillRect(0,32,32,20,BLACK);// itstime =micros();} while ((micros()-eventime) >= 200) { digitalWrite(powerx, LOW); eventime=micros();} } int8_t posr,posrm,posrr,posrrm,randy,randy2; void machCATZ() { if (posr >randy2) {posrm=1;randy2=random(20,5);} if (posrm ==1) {posr--;} if (posr <1) {posrm =0;} if (posrm ==0) {posr++;} if (posrr >randy) {posrrm=1; randy=random(55,10);} if (posrrm ==1) {posrr--; } if (posrr <1) {posrrm =0;} if (posrrm ==0) {posrr++;} display.drawBitmap(55-posrr, 20-posr,cat,66, 46, WHITE); if (randy > 11 && randy <13){ } } void istserial(void){ if(Serial3.available()>0) { int cachs = Serial3.read(); irgentwas += (char)cachs; lang++;neuda=1; if (lang > 100) {lang=0;irgentwas="";} } display.setCursor(5,5);display.setTextSize(1);display.setTextColor(WHITE); display.println(irgentwas); } void OLEDzeugs(void) { display.drawRect(0, 0, 72, 24, WHITE); //ramen x,y,w,h display.setTextColor(WHITE); display.setTextSize(3); display.setCursor(0,0); if (fuel < 99) {display.print(" ");} if (fuel < 999) {display.print(" ");} display.print(fuel);display.println("?"); display.display(); } void steptry(void){ speedy=0; while (digitalRead(tpower)== HIGH) { while ((micros()-ticktack) >= 2) { if (speedy ==0) {digitalWrite(powerx, HIGH);} if (speedy ==1) {digitalWrite(powerx, LOW);} if (speedy ==2) {digitalWrite(rot, HIGH);} speedy++; if (speedy >=(fuel+2)) {speedy=0;digitalWrite(rot, LOW);} ticktack= micros(); } }} long wusch=micros(); void lettherebelight(void) { if (bright > 255){light=bright-255; darkness=0;} if (bright <=255){darkness=(255-(bright)); light=0;} while ((micros()-wusch) >= 2) { for (uint16_t fcount1=0; fcount1 <(511); fcount1++) { if (fcount1 == ((255+darkness)-dutys[0])) { digitalWrite(rot, HIGH );} if (fcount1 == ((255+darkness)-dutys[1])) { digitalWrite(grun, HIGH );} if (fcount1 == ((255+darkness)-dutys[2])) { digitalWrite(blau, HIGH );} if (fcount1 == ((255+darkness)-dutys[3])) { digitalWrite(kan, HIGH );} // if (fcount1 == ((255+darkness)-dutys[4])) { digitalWrite(weis2, HIGH );} //if (fcount1 == ((255+darkness)-dutys[5])) { digitalWrite(weis3, HIGH );} if (fcount1 == ((255+darkness)-dutys[6])) { digitalWrite(weisnicht1, LOW );} if (fcount1 == ((255+darkness)-dutys[7])) { digitalWrite(weisnicht2, LOW );} if (fcount1 == ((255+darkness)-dutys[8])) { digitalWrite(weisnicht3, LOW );} if (fcount1 == ((255+darkness)-dutys[9])) { digitalWrite(weisnicht4, LOW );} if (fcount1 == ((255+darkness)-dutys[10])) { digitalWrite(weisnicht5, LOW );} if (fcount1 == ((255+darkness)-dutys[11])) { digitalWrite(weisnicht6, LOW );} if (fcount1 >= (256 + light) ) { digitalWrite(rot, LOW ); digitalWrite(grun, LOW ); digitalWrite(blau, LOW ); digitalWrite(kan, LOW ); // digitalWrite(weis2, LOW ); digitalWrite(weis3, LOW ); digitalWrite(weisnicht1, HIGH ); digitalWrite(weisnicht2, HIGH ); digitalWrite(weisnicht3, HIGH ); digitalWrite(weisnicht4, HIGH ); digitalWrite(weisnicht5, HIGH ); digitalWrite(weisnicht6, HIGH ); }} wusch = micros(); } } uint8_t duty1,duty2,duty3; void rgbcalc(void) { if(RGB >=0 && RGB <=150) {duty1 =150; duty2 =RGB; duty3 =0;} //rot ->gelb (rotmax grün+ blau0) if(RGB >=151 && RGB <=301) {duty1 =150 -(RGB -151); duty2 =150; duty3 =0;} //gelb ->grün (rot- grünmax blau0) if(RGB >=302 && RGB <=452) {duty1 =0; duty2 =150; duty3 =(RGB - 302);} //grün ->cyan (rot0 grünmax blau+) if(RGB >=453 && RGB <=603) {duty1 =0; duty2 =150 -(RGB - 453); duty3 =150;} //cyan ->blau (rot0 grün- blaumax) if(RGB >=604 && RGB <=754) {duty1 =(RGB-604); duty2 =0; duty3 =150;} //blau ->lila (rot+ grün0 blaumax) if(RGB >=755 && RGB <=905) {duty1 =150; duty2 =0; duty3 =150- (RGB -756);} //lila ->rot (rotmax grün0 blau-) if(RGB >= 906) {RGB=0;} } /* /* * MEOW! For using the SSD1306 I2C onb STM32F1203C8T6 with adafruit * by marderchen =^.^= its free use it or parts if there is something usefull * do what you want! * ___ * _.-| | / |\__/,| (`\ { | | -- |^ ^ |__ _) ) "-.|___| \ _.( Y ) ` / .--'-`-. _((_ `^--' /__< \ ....-+|______|__.-||__)`-' (((/ (((/ CATS are awesome! */