Skip to content

Instantly share code, notes, and snippets.

#include <OBD2.h>
#include <DueTimer.h>
#include "SamNonDuePin.h"
/********************************************************************
This example is built upon the CANAcquisition class and the OBDParmameter class using extended OBD2 ID's
This example shows how to set up periodic data acquisition of OBD2 paramters based upon
standard PID's. If you'd like to add another paramter,simply copy one of the definitions and modify it accordingly.
You may also need to add a new PID to the "OBD_PID" enum in the header file.
/********************************************************************/
// This is a VERY quick sketch as a proof of concept to see if we can start a car via SWCAN. This code won't work as-is, the data shown is dummy data.
#include <mcp_can.h>
#include <SPI.h>
#include "SamNonDuePin.h"
const int Red = 32;
const int Yellow1 = X0;
const int Yellow2 = 27;
const int Green = 23;
@macchina
macchina / 12VIO_test.INO
Last active August 23, 2020 21:57
Sketch to test PWM on the 12volt I/O (SOURCES 12volt)
#define MASTER_CLOCK 84000000
#include "SamNonDuePin.h"
uint32_t clock_a = 42000000; // Sampling frequency in Hz
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
const int IOENABLE = 6; // the number of the 12Vio_EN pin
/*
Fade
Modified 6/6/16 to demonstrate Macchina 2.0 RGB LEDs,
also functioning as a HELLO WORLD type sketch.
This example shows how to fade an LED on the RGB LED
using the analogWrite() function.
The analogWrite() function uses PWM, so if
@macchina
macchina / LowPowerControl.INO
Created June 21, 2016 16:34
Demonstrates how to turn on and off switched 12V and 5V rails.
#include "SamNonDuePin.h"
const int LPC = PIN_EMAC_ERX0; // LOW POWER CONTROL pin
void setup() {
pinModeNonDue(LPC, OUTPUT);
digitalWriteNonDue(LPC, LOW); // LOW = no power at +12V_SW/+5V_SW
// HIGH = power at +12V_SW/+5V_SW
}
@macchina
macchina / PWM_nVPW.INO
Created June 21, 2016 17:21
Controls PWM/VPW level
#include "SamNonDuePin.h"
const int LPC = PIN_EMAC_ERX0; // LOW POWER CONTROL pin
const int PWM_nVPW = PIN_EMAC_EMDC; // PWM/VPW level control
void setup() {
pinModeNonDue(LPC, OUTPUT);
pinModeNonDue(PWM_nVPW, OUTPUT);
digitalWriteNonDue(LPC, HIGH); // LOW = no power at +12V_SW/+5V_SW
@macchina
macchina / ButtonTest.INO
Created July 19, 2016 15:13
Demonstrates using "Non-Due" pins for Button inputs and LED outputs.
/*
Demonstrates using "Non-Due" pins for Button inputs and LED outputs.
*/
#include "Arduino.h"
#include "SamNonDuePin.h"
// constants won't change. They're used here to
// set pin numbers:
const int SW1 = X1; // Pushbutton SW1
/*
Heavily modified from below code - works with NEOPIXEL 24 pos ring and M2 hardware.
Program Name: blueShift
Version: v0.7
Author: Pete Mills
Website: petemills.blogspot.com
Email: mills.pete@gmail.com
@macchina
macchina / M2_9141_READ.INO
Created July 26, 2016 19:30
ISO9141 read example for M2
/*
* Example based on code found here.
* https://github.com/iwanders/OBD9141
*
* Put the "OBD9141 in Libraries folder.
*
*/
#include "OBD9141.h"
#include "SamNonDuePin.h"
@macchina
macchina / flashers.INO
Last active April 16, 2018 17:27
Send CAN message to make flashers flash in 2006 Ford Fusion.
// Demo showing how to send CAN message to make flashers flash in 2006 Ford Fusion.
#include "variant.h"
#include <due_can.h>
#include "SamNonDuePin.h"
#define Serial SerialUSB
const int LOWPOW = PIN_EMAC_ERX0;