#include #include #include #ifdef __AVR__ #include #endif #define PIN 6 #define NUM_LEDS 3 #define BRIGHTNESS 2 Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800); int gamma[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, 51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68, 69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89, 90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114, 115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142, 144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175, 177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213, 215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 }; int colormap[3][10] = {0,0,10, 50,0,0, 45,5,0, 40,10,0, 35,15,0, 30,20,0, 25,25,0, 20,30,0, 15,35,0, // 10,40,0, }; // G, R, B /* This sample code demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object. It requires the use of SoftwareSerial, and assumes that you have a 4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx). */ static const int RXPin = 2, TXPin = 3; static const uint32_t GPSBaud = 9600; int i=0,k=0,m=0; int v; float o = 7.6543; // The TinyGPS++ object TinyGPSPlus gps; // The serial connection to the GPS device SoftwareSerial ss(RXPin, TXPin); void setup() { Serial.begin(115200); ss.begin(GPSBaud); #if defined (__AVR_ATtiny85__) if (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif strip.setBrightness(BRIGHTNESS); strip.begin(); strip.show(); // Serial.println(F("FullExample.ino")); Serial.println(F("An extensive example of many interesting TinyGPS++ features")); Serial.print(F("Testing TinyGPS++ library v. ")); Serial.println(TinyGPSPlus::libraryVersion()); Serial.println(F("by Mikal Hart")); Serial.println(); Serial.println(F("Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum")); Serial.println(F(" (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail")); Serial.println(F(" ----------------------------------------------------------------------------------------------------------------------------------------")); /* // Some example procedures showing how to display to the pixels: colorWipe(strip.Color(255, 0, 0), 50); // Red colorWipe(strip.Color(0, 255, 0), 50); // Green colorWipe(strip.Color(0, 0, 255), 50); // Blue //colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW // Send a theater pixel chase in... theaterChase(strip.Color(127, 127, 127), 50); // White theaterChase(strip.Color(127, 0, 0), 50); // Red theaterChase(strip.Color(0, 0, 127), 50); // Blue rainbow(20); rainbowCycle(20); theaterChaseRainbow(50); */ } void loop() { // strip.setPixelColor(0, strip.Color(0,240,0, 0 ) ); // Green // if(i<10) strip.setPixelColor(0, strip.Color(0,240,0, 0 ) ); // Green // if(i>=10) strip.setPixelColor(0, strip.Color(240,140,0, 0 ) ); // Yellow // if(i>20)strip.setPixelColor(0, strip.Color(240,0,0, 0 ) ); // Red // strip.show(); v=gps.speed.kmph(); // if (k ==10) {k=0; } // if (i ==10) {i=0; k++;} int hunni=9,tenner=9,einser=9; i=(hunni*100)+(tenner*10)+einser; while (v!=i) //...generate color code with i++ { //vi ++ von oben nach unten if (hunni*100>v)hunni--; if (tenner*10>v)tenner--; if (einser>v)einser--; i=((hunni*100)+(tenner*10)+einser); } if (v>=0) { strip.setPixelColor(0, Wheel(hunni*18)); strip.setPixelColor(1, Wheel(tenner*18)); strip.setPixelColor(2, Wheel(einser*18)); strip.show(); } else { strip.setPixelColor(0, strip.Color(0,0,0, 0 ) ); strip.setPixelColor(1, strip.Color(0,0,0, 0 ) ); strip.setPixelColor(2, strip.Color(0,0,0, 0 ) ); strip.show(); } //i++; Serial.print(v);Serial.print(" "); Serial.print(i);Serial.print(" "); Serial.print(gps.speed.kmph());Serial.print(" "); Serial.print( gps.speed.isValid());Serial.print(" "); //delay(500); gpsread(); } // This custom version of delay() ensures that the gps object // is being "fed". static void smartDelay(unsigned long ms) { unsigned long start = millis(); do { while (ss.available()) gps.encode(ss.read()); } while (millis() - start < ms); } static void printFloat(float val, bool valid, int len, int prec) { if (!valid) { while (len-- > 1) Serial.print('*'); Serial.print(' '); } else { Serial.print(val, prec); int vi = abs((int)val); int flen = prec + (val < 0.0 ? 2 : 1); // . and - flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1; for (int i=flen; i 0) sz[len-1] = ' '; Serial.print(sz); smartDelay(0); } static void printDateTime(TinyGPSDate &d, TinyGPSTime &t) { if (!d.isValid()) { Serial.print(F("********** ")); } else { char sz[32]; sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year()); Serial.print(sz); } if (!t.isValid()) { Serial.print(F("******** ")); } else { char sz[32]; sprintf(sz, "%02d:%02d:%02d ", t.hour(), t.minute(), t.second()); Serial.print(sz); } printInt(d.age(), d.isValid(), 5); smartDelay(0); } static void printStr(const char *str, int len) { int slen = strlen(str); for (int i=0; i 5000 && gps.charsProcessed() < 10) Serial.println(F("No GPS data received: check wiring")); } // Fill the dots one after the other with a color void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; i