Guest User

dismiss leaf startup dialogue

a guest
Nov 16th, 2020
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //see https://www.mynissanleaf.com/viewtopic.php?p=593735#p593735 for details
  2. #include <avr/sleep.h>
  3. #include <mcp2515.h>  //https://github.com/autowp/arduino-mcp2515
  4. uint8_t sleepPin = 9; //for CAN transciever
  5. uint8_t csPin = 10;   //for CAN controller
  6. struct can_frame canMsg1 = { 0x681, 8, 0x04, 0x10, 0x40, 0x0D, 0xAB, 0xFF, 0xFF, 0xFF };
  7. struct can_frame canMsg2 = { 0x681, 8, 0x04, 0x20, 0x40, 0x0D, 0xAB, 0xFF, 0xFF, 0xFF };
  8. struct can_frame canMsg3 = { 0x681, 8, 0x04, 0x30, 0x40, 0x0D, 0xAB, 0xFF, 0xFF, 0xFF };
  9. MCP2515 mcp2515(csPin);
  10.  
  11. void setup() {
  12.   set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  13.   sleep_enable();  
  14.   pinMode(sleepPin, OUTPUT);
  15.   digitalWrite(sleepPin, LOW);
  16.   Serial.begin(115200);
  17.   while (!Serial); //only for boards with native usb
  18.   SPI.begin();
  19.   mcp2515.reset();
  20.   mcp2515.setBitrate(CAN_500KBPS, MCP_8MHZ); //check your quartz on mcp2515
  21.   mcp2515.setNormalMode();
  22.   Serial.println("Killing blue screen...");
  23. }
  24.  
  25. void loop() {
  26.   delay(8000); //delay for starting vehicle 8s
  27.   mcp2515.sendMessage(&canMsg1);
  28.   Serial.println("Message 1 sent");
  29.   delay(100);
  30.   mcp2515.sendMessage(&canMsg2);
  31.   Serial.println("Message 2 sent");
  32.   delay(100);
  33.   mcp2515.sendMessage(&canMsg3);
  34.   Serial.println("Message 3 sent");
  35.   delay(100);
  36.   Serial.println("Blue screen was killed!");
  37.   while (true){
  38.     digitalWrite(sleepPin, HIGH); //shutdown transciever
  39.     mcp2515.setSleepMode();       //shutdown controller
  40.     sleep_mode();                 //shutdown cpu
  41.     //shouldn't wake up, but just in case.
  42.   }
  43. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×