Skip to content

Instantly share code, notes, and snippets.

@macchina
macchina / boards.txt
Last active August 29, 2015 14:17
boards.txt addition for Macchina 1.0/1.1
##############################################################
macchina.name=Macchina
macchina.vid.0=0x2341
macchina.pid.0=0x003f
macchina.vid.1=0x2341
macchina.pid.1=0x0044
macchina.upload.tool=avrdude
@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
@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 / hsmci_example.ino
Created August 3, 2016 18:30
HSMCI speed test
/*
Test code for SD_HSMCI library
Initialises and reads the SD card properties before writing 5 files of between 5120 bytes
and 5120000 bytes to the root directory of the card. The time taken for each file write
and read is printed to the initialised Serial out. 512 is the blocksize set so this should
give optimum performance.
No checking for free space is done on the SD card.
Card detect works on the Duet, it will wait for a card to be inserted.
/*
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: [email protected]
// Demo program for testing DIGI cellular module.
// Looks for "Emergency flasher button was pressed" CAN message in 2006 Ford Fusion and sends text.
// Digi module needs to be set up to send SMS first for this sketch to work:
// http://www.digi.com/resources/documentation/digidocs/90001525/default.htm
// Specifically this example:
// http://www.digi.com/resources/documentation/digidocs/90001525/default.htm#tasks/t_send_sms.htm%3FTocPath%3DGetting%2520started%7CExamples%7C_____2
#include "variant.h"
#include <due_can.h>
#include "SamNonDuePin.h"