void setup()/*----( SETUP: RUNS ONCE )----*/ { lcd.begin(20, 4); // initialize the lcd for 20 chars 4 lines and turn on backlight // Open serial communications and wait for port to open: Serial.begin(9600); // --- button setup pinMode(RunBtn, INPUT); pinMode(ChangeScanBtn, INPUT); digitalWrite(RunBtn, HIGH); digitalWrite(ChangeScanBtn, HIGH); pinMode(clampPin, OUTPUT); // sets the digital pin as OUTPUT to drive FET clamp) pinMode(5, OUTPUT); // sets the digital pin as output pinMode(6, OUTPUT); // sets the digital pin as output pinMode(7, OUTPUT); // sets the digital pin as output pinMode(11, OUTPUT); // pin11= PWM output / frequency output //Will Turner - This could go to pin 5 from 11. CHANGED TO 9 AS IT WOULDNT REACH OTHERS // ------- Quick 3 blinks of backlight ------------- for (int i = 0; i < 3; i++) { lcd.backlight(); delay(20); lcd.noBacklight(); delay(20); } lcd.backlight(); // finish with backlight on //-------- Initialise display ---------------- // NOTE: Cursor Position: CHAR, LINE) start at 0 lcd.setCursor(0, 0); //Start at character 0 on line 0 lcd.print("Tension Tester v1.5 "); // sets up the screen for the wire number and layer number being recorded lcd.setCursor(0, 2); lcd.print(" Press Run "); Setup_timer2(); // disable interrupts to avoid timing distortion cbi (TIMSK0, TOIE0); // disable Timer0 !!! delay() is now not available sbi (TIMSK2, TOIE2); // enable Timer2 Interrupt dfreq = 1000.0; // initial output frequency = 1000.o Hz tword_m = pow(2, 32) * dfreq / refclk; // calulate DDS new tuning word // setup start and end frequencies of sweep // setup initial values for loop adcflag = false; analogval = 0; digitalWrite(clampPin, HIGH); // sets the pin high to short out large signals before amp (using a FET as clamp) avgcnt = 0.0; }
void flashx3() { // ------- Quick 3 blinks of backlight ------------- for (int i = 0; i < 3; i++) { lcd.backlight(); delay(2000); lcd.noBacklight(); delay(2000); } lcd.backlight(); // finish with backlight on //-------- Initialise display ---------------- }
void setup() { Serial.begin(115200); //Setup Channel A pinMode(X_DIR_PIN, OUTPUT); //Initiates Motor Channel A pin pinMode(Y_DIR_PIN, OUTPUT); //Initiates Motor Channel A pin pinMode(9, OUTPUT); //Initiates Brake Channel A pin pinMode(A0,INPUT); pinMode(X_MIN_PIN,INPUT_PULLUP); pinMode(X_MAX_PIN,INPUT_PULLUP); pinMode(X_JOY_LEFT,INPUT_PULLUP); pinMode(X_JOY_RIGHT,INPUT_PULLUP); pinMode(Y_JOY_DOWN,INPUT_PULLUP); pinMode(Y_JOY_UP,INPUT_PULLUP); // Quadrature encoders // X encoder pinMode(c_XEncoderPinA, INPUT); // sets pin A as input digitalWrite(c_XEncoderPinA, LOW); // turn on pullup resistors pinMode(c_XEncoderPinB, INPUT); // sets pin B as input digitalWrite(c_XEncoderPinB, LOW); // turn on pullup resistors attachInterrupt(c_XEncoderInterrupt, HandleLeftMotorInterruptA, RISING); // Y encoder pinMode(c_YEncoderPinA, INPUT); // sets pin A as input digitalWrite(c_YEncoderPinA, LOW); // turn on pullup resistors pinMode(c_YEncoderPinB, INPUT); // sets pin B as input digitalWrite(c_YEncoderPinB, LOW); // turn on pullup resistors attachInterrupt(c_YEncoderInterrupt, HandleRightMotorInterruptA, RISING); lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight // ------- Quick 3 blinks of backlight ------------- for(int i = 0; i< 3; i++) { lcd.backlight(); delay(150); lcd.noBacklight(); delay(150); } lcd.backlight(); // finish with backlight on //-------- Write characters on the display ------------------ // NOTE: Cursor Position: Lines and Characters start at 0 lcd.setCursor(3,0); //Start at character 4 on line 0 lcd.print("Hello, world!"); }/*--(end setup )---*/
void WeatherStation::processButton() { #define GOTOSLEEP_TIME 2 //s setCurrentDate(); buttonPressHours = runHours; buttonPressMinute = currentMinute; if ( DISPLAY_STATE_INIT == displayMgt.state ) { lcd.backlight(); lcd.setCursor(0,0); lcd.print("Weather Station"); //16 lcd.setCursor(0,1); lcd.print("*** DFRobot ***"); //16 addAction(ACTION_SAMPLE_DATA); } addAction(ACTION_DISPLAY); overTime = SLEEP_OVERTIME; /**to avoid RTC interrupt when goto sleep **/ if ( (59 == currentMinute) && ( (currentSecond + overTime + GOTOSLEEP_TIME) >= 60 )) { overTime += (GOTOSLEEP_TIME + 1); } }
void init() { Serial.begin(SERIAL_BAUD_RATE); Serial.systemDebugOutput(true); // Allow debug print to serial Serial.println("Sming. Let's do smart things!"); Wire.pins(2, 0); lcd.begin(16, 2); lcd.backlight(); lcd.clear(); lcd.setCursor(0, 0); lcd.print("DATE: 00/00/0000"); lcd.setCursor(0, 1); lcd.print("TIME: 00:00"); // Station - WiFi client WifiStation.enable(true); WifiStation.config(WIFI_SSID, WIFI_PWD); // Put you SSID and Password here // set timezone hourly difference to UTC SystemClock.setTimeZone(7); // Run our method when station was connected to AP (or not connected) WifiStation.waitConnection(connectOk, 30, connectFail); // We recommend 20+ seconds at start }
// The loop function is called in an endless loop void loop() { delay(SENSOR_CHANGE_TRIGGER_TIME); unsigned long unchangedTime = millis() - lastMotionDetected; if (unchangedTime < MAX_ON_TIME) { lcd.display(); lcd.backlight(); switch (sensor) { case TEMPERATURE_SENSOR_NUM: setTemperature(); break; case HUMIDITY_SENSOR_NUM: setHumidity(); break; case SOIL_SENSOR_NUM: setSoilHumidity(); break; case PRESSURE_SENSOR_NUM: setPressure(); break; } } else { lcd.noDisplay(); lcd.noBacklight(); } delay(500); }
void init() { spiffs_mount(); // Mount file system, in order to work with files Serial.begin(SERIAL_BAUD_RATE); // 115200 by default Serial.systemDebugOutput(false); // Debug output to serial ActiveConfig = loadConfig(); // Select control line pinMode(CONTROL_PIN, OUTPUT); // DHT sensor start dht.begin(); lcd.begin(16, 2); lcd.backlight(); lcd.createChar(1, icon_termometer); lcd.createChar(2, icon_water); lcd.createChar(3, celsius); lcd.createChar(4, icon_retarrow); lcd.createChar(5, icon_clock); lcd.createChar(6, icon_cross); lcd.createChar(7, icon_check); WifiStation.config(ActiveConfig.NetworkSSID, ActiveConfig.NetworkPassword); WifiStation.enable(true); WifiAccessPoint.enable(false); WifiStation.waitConnection(connectOk, 20, connectFail); // We recommend 20+ seconds for connection timeout at start procTimer.initializeMs(5000, process).start(); process(); }
LCD::LCD(Cooler *cooler, CheeseDHT *dhtUp, CheeseDHT *dhtDown, CheeseLog* logger) { this->cooler = cooler; this->logger = logger; this->dhtUp = dhtUp; this->dhtDown = dhtDown; Wire.begin(4, 5); currentLCD.init(); currentLCD.backlight(); counter = 0; }
void init() { spiffs_mount(); Serial.begin(230400); // 115200 by default Serial.systemDebugOutput(false); // Enable debug output to serial Wire.begin(); lcd.begin(16,2); // initialize the lcd for(int i = 0; i< 3; i++) { lcd.backlight(); delay(150); lcd.noBacklight(); delay(250); } lcd.backlight(); lcd.setCursor(0,0); lcd.clear(); lcd.print(" Music Box "); lcd.setCursor(0,1); lcd.print(" Geek Labs "); SystemClock.setTimeZone(3); printTimer.initializeMs(1000*60, onPrintSystemTime).start(); Serial.begin(SERIAL_BAUD_RATE); // 115200 by default Serial.systemDebugOutput(true); // Enable debug output to serial WifiStation.enable(true); WifiStation.config(WIFI_SSID, WIFI_PWD); WifiAccessPoint.enable(false); Wire.beginTransmission(PT2258_ADDRESS); Wire.write(0xC0); Wire.endTransmission(); // Run our method when station was connected to AP WifiStation.waitConnection(connectOk, 30, connectFail); }
void setPower(int state){ power = state; lcd.setCursor(0,1); if(state==1){ lcd.print(" Power ON "); lcd.backlight(); }else{ lcd.print(" Power OFF "); lcd.noBacklight(); } }
void setup() { Serial.begin(9600); pinMode(SOILSENSOR, INPUT); pinMode(PUMPPIN, OUTPUT); // initialize the LCD lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("Initializing..."); dht.begin(); }
void navigationInit(PiezoEffects * mySounds) { navigationSounds = mySounds; //lcd buttons pinMode(LCD_UP_PIN, INPUT_PULLUP); pinMode(LCD_DOWN_PIN, INPUT_PULLUP); pinMode(LCD_PLAY_PIN, INPUT_PULLUP); pinMode(LCD_STOP_PIN, INPUT_PULLUP); // initialize the LCD lcd.begin(); lcd.backlight(); lcd.print("Geekbot Navigator"); }
void WeatherStation::enableAfterSleep() { uint8_t i; volatile uint8_t *out, *ddr; uint16_t diffMinutes; //enable power digitalWrite( PALETTE_PIN_MVCC, LOW ); pinMode( PALETTE_PIN_MVCC, OUTPUT ); delay(50); //waiting power stable /**recovery ports**/ for( i = 0; i < PALETTE_PORT_NUM; i++ ) { ddr = portModeRegister(ioPort[i]); out = portOutputRegister(ioPort[i]); *ddr = ioPreDDRValue[i]; *out = ioPrePORTValue[i]; } sensorMgt.start(); lcd.init(); //need sometimes if ( EVENT_STATE_SET == eventButtonState ) { lcd.backlight(); setCurrentDate(); diffMinutes = (uint16_t)(runHours - buttonPressHours) * 60 + currentMinute - buttonPressMinute; if ( (!displayMgt.statisticFlag) || (diffMinutes >= RESTART_DISPLAY_OVERTIME) ) { clrDisplayMgt(); } } for ( i = 0; i < ACTION_NUMBER; i++ ) { a_actionList[i].state = STATE_INIT; } startTime = (uint8_t)(millis()/1000); }
void setup() { lcd.begin(); lcd.backlight(); }
void setup() { target_lat[1] = TARGET_1_LAT; target_lon[1] = TARGET_1_LON; target_lat[2] = TARGET_2_LAT; target_lon[2] = TARGET_2_LON; target_lat[3] = TARGET_3_LAT; target_lon[3] = TARGET_3_LON; target_lat[4] = TARGET_4_LAT; target_lon[4] = TARGET_4_LON; target_lat[5] = TARGET_5_LAT; target_lon[5] = TARGET_5_LON; target_lat[6] = TARGET_6_LAT; target_lon[6] = TARGET_6_LON; target_lat[7] = TARGET_7_LAT; target_lon[7] = TARGET_7_LON; target_lat[8] = TARGET_8_LAT; target_lon[8] = TARGET_8_LON; target_lat[9] = TARGET_9_LAT; target_lon[9] = TARGET_9_LON; target_lat[10] = TARGET_10_LAT; target_lon[10] = TARGET_10_LON; target_lat[11] = TARGET_11_LAT; target_lon[11] = TARGET_11_LON; target_lat[12] = TARGET_12_LAT; target_lon[12] = TARGET_12_LON; target_lat[13] = TARGET_13_LAT; target_lon[13] = TARGET_13_LON; target_lat[14] = TARGET_14_LAT; target_lon[14] = TARGET_14_LON; target = EEPROM.read(EEPROM_TARGET_INDEX); if(target > NUMBER_OF_TARGETS+2 || target == 0 /*|| TARGET_RESET > 0*/) { target = 1; EEPROM.write(EEPROM_TARGET_INDEX, target); } // Force next step on strtup //target++; //EEPROM.write(EEPROM_TARGET_INDEX, target); // Init pin outputs pinMode(BATTERY_VOLTAGE_PIN, INPUT); pinMode(BUTTON_PIN, INPUT); pinMode(LED_PIN, OUTPUT); pinMode(SERVO_ON_PIN, OUTPUT); pinMode(ON_PIN, INPUT); pinMode(LCD_POWER_PIN, OUTPUT); pinMode(GPS_RX_PIN, INPUT); digitalWrite(LCD_POWER_PIN, 1); digitalWrite(SERVO_ON_PIN, 0); servo.attach(SERVO_PIN); analogReference(EXTERNAL); ss.begin(9600); Serial.begin(115200); lcd.init(); lcd.backlight(); lcd_welcome(lcd); wait w; w.set_time(3000); w.start(); wait sim; w.set_time(30000); sim.set_steps(7); sim.start(); Serial.print(F("Free RAM:")); Serial.println(freeRam()); Serial.println(F("Setup done.")); }
void DisplayClass::backlight() const { lcd.backlight(); }
void setup() { tmElements_t currentTime; currentTime.Second = 0; currentTime.Minute = 35; currentTime.Hour =18; currentTime.Wday = 5; currentTime.Day = 17; currentTime.Month = 4; currentTime.Year = 44; // RTC.set(makeTime(currentTime)); Serial.begin(9600); Serial.println("TerraMonitor starting ..."); Wire.begin(); // analogReference(INTERNAL); Serial.print("EEPROM HumidityController size occupied (in bytes) : "); Serial.println(EEPROM_HUMIDITY_CONTROLLER_SIZE); setSyncProvider(RTC.get); // the function to get the time from the RTC if(timeStatus()!= timeSet) Serial.println("Unable to sync with the RTC"); else Serial.println("RTC has set the system time"); /* Controller Alarm init */ humidityController.initAlarms(); lightController.initAlarms(); /* read the sensor every s */ lowSensor.setInterval(5000); highSensor.setInterval(5000); /* read the sensor every 10s */ humidTempSensor.setInterval(10000); /* run temp controller every s */ tempController.setInterval(1000); /* add the thread to the controller */ controller.add(&lowSensor); controller.add(&highSensor); controller.add(&humidTempSensor); controller.add(&tempController); Timer1.initialize(100000); Timer1.attachInterrupt(timerCallback); // Alarms //Alarm.alarmRepeat(12,00,0, MorningAlarm); // 8:30am every day // Alarm.alarmRepeat(14,48,0, MorningAlarm); // 8:30am every day //Alarm.alarmRepeat(17,30,0, MorningAlarm); // 8:30am every day //Alarm.alarmRepeat(22,15,0, MorningAlarm); // 8:30am every day humidityController.disableAllAlarms(); humidityController.setAlarm(0, 12, 0, 0, 30); humidityController.setAlarm(1, 14, 0, 0, 15); humidityController.setAlarm(2, 16, 0, 0, 15); humidityController.setAlarm(3, 20, 0, 0, 15); humidityController.setAlarm(4, 22, 15, 0, 20); // humidityController.setAlarm(4, 16, 10, 0, 10); lightController.setStartTime(11,30,0); lightController.setStopTime(23,30,0); tempController.setMaxUpperTemp(29); tempController.setMinDayLowerTemp(21); tempController.setMinNightLowerTemp(20); tempController.setMinNightUpperTemp(21); // extractFan.startFan(); // sideFan.startFan(); // frontFan.startFan(); lcd.init(); // initialize the lcd // Print a message to the LCD. lcd.backlight(); }
void WeatherStation::init( DataConfig *p_dataConfig, uint8_t dataNum ) { uint8_t i, index; DataConfig *p_dataConfigRecord = NULL; /**init config table**/ p_dataConfigRecord = p_dataConfig; index = 0; DBG_PRINTLN("measure table:"); for( i = 0; i < dataNum; i++ ) { a_measureData[index].p_sensor = sensorMgt.creatObject( p_dataConfigRecord->sensorID, p_dataConfigRecord->attachPin, p_dataConfigRecord->auxiliaryPin ); if ( NULL == a_measureData[index].p_sensor ) { String info; info = "Error: Rule No."; info += (i+1); showErrInfo( info ); break; } a_measureData[index].dataType = p_dataConfigRecord->type; a_measureData[index].valid = true; dataHouse.addDataTypeIndex(a_measureData[index].dataType); DBG_PRINTLN_VAR(index, DEC); DBG_PRINTLN_VAR((word)a_measureData[index].p_sensor, HEX); index++; p_dataConfigRecord++; } measureNum = index; //todo enable power digitalWrite( PALETTE_PIN_MVCC, LOW ); pinMode( PALETTE_PIN_MVCC, OUTPUT ); delay(500); //waiting power stable /**init devices**/ Wire.begin(); RTCObj.begin(); lcd.init(); lcd.backlight(); setCurrentDate(); dataHouse.init( currentYear, currentMonth, currentDate, currentHour ); sensorMgt.start(); /**get the state of Switch**/ pinMode(PALETTE_PIN_SW, INPUT_PULLUP); switchState = digitalRead(PALETTE_PIN_SW); /**attach interrupt**/ pinMode(STAION_PIN_RTC_INT, INPUT_PULLUP); pinMode(STAION_PIN_BUTTON, INPUT ); PCattachInterrupt( STAION_PIN_RTC_INT ); PCattachInterrupt( STAION_PIN_BUTTON ); RTCObj.clearINTStatus(); #if _DEBUG RTCObj.enableInterrupts(EveryMinute); #else RTCObj.enableInterrupts(EveryHour); #endif /**Start**/ pinMode(PALETTE_PIN_BLK, OUTPUT); digitalWrite(PALETTE_PIN_BLK,HIGH); startTime = (uint8_t)(millis()/1000); /**emulate pushing button**/ setEvent( STAION_PIN_BUTTON ); }
void LcdBacklight() { lcd27.backlight(); lcd3E.backlight(); }
// { SPECIAL FUNCTIONS ------------------------------------------------------- void setup(){ // Required if SYSTEM_MODE = SEMI_AUTOMATIC or MANUAL // if(Particle.connected() == false){ // Particle.connect(); // } pinMode(BOARD_LED, OUTPUT); //INPUT, INPUT_PULLUP, INPUT_PULLDOWN or OUTPUT // pinMode(DAC, OUTPUT); //INPUT, INPUT_PULLUP, INPUT_PULLDOWN or OUTPUT // pinMode( D6, INPUT ); // attachInterrupt( D6, on_d6, CHANGE, 13); // Note: do not set the pinMode() with analogRead(). The pinMode() is // automatically set to AN_INPUT the first time analogRead() is called // src: https://docs.particle.io/reference/firmware/photon/#analogread-adc- // In other words, don't do: pinMode(analog_pin, INPUT); // { Declare Cloud Variables/Functions/Events ---------------------------- // Up to 20 Variables Particle.variable("help", HELP); Particle.variable("a", PV_a); Particle.variable("b", PV_a); Particle.variable("c", PV_a); // Up to 15 Functions. Particle.function("do", PF_do); Particle.function("set", PF_set); #ifdef USE_STDIN Particle.function("stdin", PF_stdin); #endif // USE_STDIN // Up to 4 Event Subscriptions Particle.subscribe("all", PS_handler, MY_DEVICES); // For documentation specify what events you will publish: // Particle.publish("stdout", "...") // Particle.publish("stderr", "...") // } Declare Cloud Variables/Functions/Events ---------------------------- strcpy(PV_a, "Hello World"); #ifdef USE_LCD lcd.init(); lcd.backlight(); lcd.clear(); lcd.setCursor(0,1); lcd.print("Hello World"); #endif #ifdef USE_SERIAL0 Serial.begin(9600); #endif // USE_SERIAL0 #ifdef USE_SERIAL1 Serial1.begin(9600); #endif // USE_SERIAL1 #ifdef USE_TIMER_2SEC timer_2sec.start(); #endif // USE_TIMER_2SEC }