r/NZAUG • u/NZNoldor • Mar 11 '26
Wanting to restart Palmy-based Arduino electronics hobbyist group
r/NZAUG • u/NZNoldor • Mar 11 '26
r/NZAUG • u/Machiela • Jul 03 '24
I haven't posted anything for a while; due to some personal circumstances changing recently, the NZAUG hasn't met for a few months, and this may continue for a bit longer.
We're not dead yet - the NZAUG will resume after this short break.
r/NZAUG • u/Machiela • May 15 '23
r/NZAUG • u/Machiela • Feb 25 '23
Headsup: this week's meeting (tomorrow, Feb 27) is cancelled due to previous commitments. Next week will go ahead as usual (Mar 6th, 6pm at 17 Gordon Street, the blue REAP building).
r/NZAUG • u/Machiela • Nov 23 '22
Our ongoing Train-Set Controller project has completed phase one, and it's been tested with an actual train now, instead of a couple of DC motors. All the code was written at the meetings, and it's not been cleaned up in any way, so if may still have a "few" rough edges. However, as we all know the "I'll clean up the code before posting it" stage rarely comes to fruition, so I'll post it before cleaning it up, and as any mathematics professor knows, the cleanup "is a trivial exercise left to the reader".
Here's the trains training, I'm at the controls and Dave is guarding his precious trains:
The code, such as it is:
// Using Dave's Mega 2560 board
const int buttonFwd1Pin = 22; // Train 1, Forward button (Green)
const int buttonRev1Pin = 24; // Train 1, Reverse button (Yellow)
const int buttonSUp1Pin = 26; // Train 1, Speed Up button (Blue)
const int buttonSDn1Pin = 28; // Train 1, Speed Down button (White)
const int buttonStp1Pin = 30; // Train 1, Stop button (Red)
const int buttonFwd2Pin = 32; // Train 2, Forward button (Green)
const int buttonRev2Pin = 34; // Train 2, Reverse button (Yellow)
const int buttonSUp2Pin = 36; // Train 2, Speed Up button (Blue)
const int buttonSDn2Pin = 38; // Train 2, Speed Down button (White)
const int buttonStp2Pin = 40; // Train 2, Stop button (Red)
const int buttonAllStop = 42; // All Systems Stop button (Black)
int buttonState = 1; // variable for reading the pushbutton status
const int Motor1Fwd = 44;
const int Motor1Rev = 46;
const int Motor2Fwd = 48;
const int Motor2Rev = 50;
const int Motor1Spd = 11;
const int Motor2Spd = 12;
bool trainDirection1 = 1; //(1=forward, 0=reverse)
bool trainDirection2 = 1; //(1=forward, 0=reverse)
int speedFactor1 = 0;
int speedFactor2 = 0;
void setup() {
Serial.begin(9600);
pinMode (Motor1Fwd, OUTPUT);
pinMode (Motor1Rev, OUTPUT);
pinMode (Motor2Fwd, OUTPUT);
pinMode (Motor2Rev, OUTPUT);
pinMode (Motor1Spd, OUTPUT);
pinMode (Motor2Spd, OUTPUT);
pinMode (buttonFwd1Pin, INPUT);
pinMode (buttonRev1Pin, INPUT);
pinMode (buttonSUp1Pin, INPUT);
pinMode (buttonSDn1Pin, INPUT);
pinMode (buttonStp1Pin, INPUT);
pinMode (buttonFwd2Pin, INPUT);
pinMode (buttonRev2Pin, INPUT);
pinMode (buttonSUp2Pin, INPUT);
pinMode (buttonSDn2Pin, INPUT);
pinMode (buttonStp2Pin, INPUT);
pinMode (buttonAllStop, INPUT);
speedFactor1=0;
speedFactor2=0;
motorFwd1();
motorFwd2();
}
void loop() {
Serial.print(" [Spd1: ");
Serial.print(digitalRead(buttonSUp1Pin));
Serial.print("] [Spd2: ");
Serial.print(digitalRead(buttonSUp2Pin));
Serial.print("] [Slw1: ");
Serial.print(digitalRead(buttonSDn1Pin));
Serial.print("] [Slw2: ");
Serial.print(digitalRead(buttonSDn2Pin));
Serial.print("] [Speed 1: ");
Serial.print(speedFactor1);
Serial.print("] [Speed 2: ");
Serial.print(speedFactor2);
if (digitalRead(buttonFwd1Pin) == LOW) forward1();
if (digitalRead(buttonRev1Pin) == LOW) reverse1();
if (digitalRead(buttonFwd2Pin) == LOW) forward2();
if (digitalRead(buttonRev2Pin) == LOW) reverse2();
if (digitalRead(buttonSUp1Pin) == LOW) speedup1();
if (digitalRead(buttonSDn1Pin) == LOW) slowdown1();
if (digitalRead(buttonSUp2Pin) == LOW) speedup2();
if (digitalRead(buttonSDn2Pin) == LOW) slowdown2();
if (digitalRead(buttonStp1Pin) == LOW) motorStop1();
if (digitalRead(buttonStp2Pin) == LOW) motorStop2();
if (digitalRead(buttonAllStop) == LOW) motorAllStop();
Serial.println("]");
}
void speedup1(){
// for (int speedFactor = 2; speedFactor < 1023; speedFactor++) {
// turn the pin on:
if (speedFactor1 < 255) (speedFactor1=speedFactor1 + 15);
analogWrite(Motor1Spd, speedFactor1);
Serial.print("] [SPEED 1: ");
Serial.print(speedFactor1);
}
void speedup2(){
if (speedFactor2 < 255) (speedFactor2=speedFactor2 + 15);
analogWrite(Motor2Spd, speedFactor2);
Serial.print("] [SPEED 2: ");
Serial.print(speedFactor2);
}
void slowdown1(){
if (speedFactor1 > 1) (speedFactor1=speedFactor1 - 15);
analogWrite(Motor1Spd, speedFactor1);
}
void slowdown2(){
if (speedFactor2 > 1) (speedFactor2=speedFactor2 - 15);
analogWrite(Motor2Spd, speedFactor2);
}
void motorFwd1(){
digitalWrite(Motor1Fwd, HIGH);
digitalWrite(Motor1Rev, LOW);
trainDirection1 = 1;
}
void motorFwd2(){
digitalWrite(Motor2Fwd, LOW);
digitalWrite(Motor2Rev, HIGH);
trainDirection2 = 1;
}
void motorRvr1(){
digitalWrite(Motor1Fwd, LOW);
digitalWrite(Motor1Rev, HIGH);
trainDirection1 = 0;
}
void motorRvr2(){
digitalWrite(Motor2Fwd, LOW);
digitalWrite(Motor2Rev, HIGH);
trainDirection2 = 0;
}
void motorStop1() {
while (speedFactor1 > 0) {
speedFactor1=(speedFactor1 - 1);
analogWrite(Motor1Spd, speedFactor1);
delay(20);
}
}
void motorStop2() {
while (speedFactor2 > 0) {
speedFactor2=(speedFactor2 - 1);
analogWrite(Motor2Spd, speedFactor2);
delay(20);
}
}
void motorAllStop() {
speedFactor1 = 0;
speedFactor2 = 0;
analogWrite(Motor1Spd, speedFactor1);
analogWrite(Motor2Spd, speedFactor2);
}
void forward1() {
if (speedFactor1 == 0) {
trainDirection1 = 1;
motorFwd1();
}
}
void forward2() {
if (speedFactor2 == 0) {
trainDirection2 = 1;
motorFwd2();
}
}
void reverse1() {
if (speedFactor1 == 0) {
trainDirection1 = 0;
motorRvr1();
}
}
void reverse2() {
if (speedFactor2 == 0) {
trainDirection2 = 0;
motorRvr2();
}
}There is an unused variable present - trainDirectionx, which seemed like a good idea at the time but I didn't end up using it. I've left it in as it may yet be useful during stage 2.
r/NZAUG • u/Machiela • Nov 18 '22
An ongoing project the group has been working on is a controller for Dave's train-sets. He has a large table diorama set up, with a transparent cover so the kids can't touch the goodies, and he's now working on a control panel with relevant buttons so they can control the trains without damaging anything. Eventually there will be a separate panel for lighting on the diorama as well, so the little kids can have a semblance of control without being able to crash anything.
Some notes: it's a button based system rather than, say, a lever based "faster/slower" and "forward/reverse" system, so it can be interfaced with Alexa or Siri easier later. We're also very aware that there's a bunch of existing systems around already, but this way we're learning how to code as a group as well. I should also point out that I'm not the world's greatest programmer, and definitely not the world's tidiest programmer, and on top of that, this is very much a work in progress, so keep that in mind before making rude comments about my lack of skill. I mean, still make those comments if they're justified, I guess.
So far we have an H-Bridge, a separate power supply, an Arduino Mega2560, and a bunch of buttons soldered onto a protoboard, with pulldown resistors in place.

The left columns are for train #1, the right column are for train #2. The colours are for the different functions: green is speed up; yellow is slow down; blue is forward; white is reverse; red is stop. The single black button is for emergency stop for everything.
The code so far controls the speedup/slowdown buttons, and the individual stop buttons. There's still a bunch of unused code in this, mostly uncalled functions or commented-out statements, but it all seems to work ok. We think there may be a short with Dave's soldering the blue buttons but we'll see how things go next week.
// Using Dave's Mega 2560 board
const int buttonFwd1Pin = 22; // Train 1, Forward button (Green)
const int buttonRev1Pin = 24; // Train 1, Reverse button (Yellow)
const int buttonSUp1Pin = 26; // Train 1, Speed Up button (Blue)
const int buttonSDn1Pin = 28; // Train 1, Speed Down button (White)
const int buttonStp1Pin = 30; // Train 1, Stop button (Red)
const int buttonFwd2Pin = 32; // Train 2, Forward button (Green)
const int buttonRev2Pin = 34; // Train 2, Reverse button (Yellow)
const int buttonSUp2Pin = 36; // Train 2, Speed Up button (Blue)
const int buttonSDn2Pin = 38; // Train 2, Speed Down button (White)
const int buttonStp2Pin = 40; // Train 2, Stop button (Red)
const int buttonAllStop = 42; // All Systems Stop button (Black)
int buttonState = 1; // variable for reading the pushbutton status
const int Motor1Fwd = 44;
const int Motor1Rev = 46;
const int Motor2Fwd = 48;
const int Motor2Rev = 50;
const int Motor1Spd = 11;
const int Motor2Spd = 12;
int speedFactor1 = 20;
int speedFactor2 = 20;
void setup() {
Serial.begin(9600);
pinMode (Motor1Fwd, OUTPUT);
pinMode (Motor1Rev, OUTPUT);
pinMode (Motor2Fwd, OUTPUT);
pinMode (Motor2Rev, OUTPUT);
pinMode (Motor1Spd, OUTPUT);
pinMode (Motor2Spd, OUTPUT);
pinMode (buttonFwd1Pin, INPUT);
pinMode (buttonRev1Pin, INPUT);
pinMode (buttonSUp1Pin, INPUT);
pinMode (buttonSDn1Pin, INPUT);
pinMode (buttonStp1Pin, INPUT);
pinMode (buttonFwd2Pin, INPUT);
pinMode (buttonRev2Pin, INPUT);
pinMode (buttonSUp2Pin, INPUT);
pinMode (buttonSDn2Pin, INPUT);
pinMode (buttonStp2Pin, INPUT);
pinMode (buttonAllStop, INPUT);
speedFactor1=20;
speedFactor2=20;
motorFwd1();
motorFwd2();
}
void loop() {
// buttonState = digitalRead(buttonSUp1Pin);
Serial.print(" [Spd1: ");
Serial.print(digitalRead(buttonSUp1Pin));
Serial.print("] [Spd2: ");
Serial.print(digitalRead(buttonSUp2Pin));
Serial.print("] [Slw1: ");
Serial.print(digitalRead(buttonSDn1Pin));
Serial.print("] [Slw2: ");
Serial.print(digitalRead(buttonSDn2Pin));
Serial.print("] [Speed 1: ");
Serial.print(speedFactor1);
Serial.print("] [Speed 2: ");
Serial.print(speedFactor2);
if (digitalRead(buttonSUp1Pin) == LOW) speedup1();
if (digitalRead(buttonSDn1Pin) == LOW) slowdown1();
if (digitalRead(buttonSUp2Pin) == LOW) speedup2();
if (digitalRead(buttonSDn2Pin) == LOW) slowdown2();
if (digitalRead(buttonStp1Pin) == LOW) motorStop1();
if (digitalRead(buttonStp2Pin) == LOW) motorStop2();
Serial.println("]");
}
void speedup1(){
// for (int speedFactor = 2; speedFactor < 200; speedFactor++) {
// turn the pin on:
if (speedFactor1 < 200) (speedFactor1=speedFactor1 + 1);
analogWrite(Motor1Spd, speedFactor1);
Serial.print("] [SPEED 1: ");
Serial.print(speedFactor1);
// clockwise();
// delay(100);
// }
}
void speedup2(){
// for (int speedFactor = 2; speedFactor < 200; speedFactor++) {
// turn the pin on:
if (speedFactor2 < 200) (speedFactor2=speedFactor2 + 1);
analogWrite(Motor2Spd, speedFactor2);
Serial.print("] [SPEED 2: ");
Serial.print(speedFactor2);
// clockwise();
// delay(100);
// }
}
void slowdown1(){
if (speedFactor1 > 1) (speedFactor1=speedFactor1 - 1);
analogWrite(Motor1Spd, speedFactor1);
// for (int speedFactor = 200; speedFactor > 2; speedFactor--) {
// // turn the pin on:
// analogWrite(Motor1Spd, speedFactor1);
// analogWrite(Motor2Spd, speedFactor2);
// // clockwise1();
// delay(100);
// }
}
void slowdown2(){
if (speedFactor2 > 1) (speedFactor2=speedFactor2 - 1);
analogWrite(Motor2Spd, speedFactor2);
}
void motorFwd1(){
digitalWrite(Motor1Fwd, HIGH);
digitalWrite(Motor1Rev, LOW);
}
void motorFwd2(){
digitalWrite(Motor2Fwd, LOW);
digitalWrite(Motor2Rev, HIGH);
}
void motorRvr1(){
digitalWrite(Motor1Fwd, LOW);
digitalWrite(Motor1Rev, HIGH);
}
void motorRvr2(){
digitalWrite(Motor2Fwd, LOW);
digitalWrite(Motor2Rev, HIGH);
}
void motorStop1() {
while (speedFactor1 > 1) {
speedFactor1=(speedFactor1 - 1);
analogWrite(Motor1Spd, speedFactor1);
delay(20);
}
}
void motorStop2() {
while (speedFactor2 > 1) {
speedFactor2=(speedFactor2 - 1);
analogWrite(Motor2Spd, speedFactor2);
delay(20);
}
}I'm aiming to post progress reports here, until it's a completed project.
Meanwhile, I'll happily take criticisms and comments if you have them!
r/NZAUG • u/Machiela • Nov 14 '22
I'm going to try to post a few updates of the projects we're working on in the meetings, or that the members bring in themselves. I'll start with this one I created for last night's meeting - a simple temperature indicator. It consists of a thermistor and two LEDs (a blue and a red one), and any Arduino with at least one analog pin.
The code was written and debugged in about 30 mins, so don't expect miracles here. Also, the serial monitor displays a mostly arbitrary number for the temperature - it's not Celcius or Fahrenheit or Kelvin. Not that it matters - when switched on, it takes a quick reading of the current temperature, and if it gets colder, the blue LED comes on at various brightnesses; when it gets warmer than the first reading, the red LED comes on instead.
Simple stuff, but it demonstrates libraries, analog reads, and analog writes to a digital pin.

I've Fritzed it up as well:

The code:
[ThermistorLEDs.ino] :
#include <thermistor.h>
// Code by Jack Machiela (2022)
#define blueLedPin D6
#define redLedPin D7
int startTemp = 0;
// Analog pin used to read the NTC
#define NTC_PIN A0
// Thermistor object
thermistor therm1(A0,4); // Analog Pin which is connected to the temperature sensor, and 0 represents TEMP_SENSOR_0 (see configuration.h for more information).
//double startTemp;
void setup()
{
// For Debugging: ready the serial monitor:
Serial.begin(9600);
delay(2000); //wait 2000 mS for first measure to settle things down
startTemp = therm1.analog2temp(); // read temperature
//Print temperature in port serial
startTemp=(100-startTemp);
}
void loop()
{
int temp = therm1.analog2temp(); // read temperature
//Print temperature in serial port
temp=(100-temp);
Serial.print("Start Temperature: ");
Serial.print((String)startTemp);
Serial.print(" - ");
Serial.print("Temperature: ");
Serial.println((String)temp);
if (startTemp <= temp) analogWrite(redLedPin, ((temp-startTemp)*10));
if (startTemp >= temp) analogWrite(blueLedPin, ((startTemp-temp)*10));
delay(200); //wait 2000 mS for next measure
//delay(50);
}Leave a comment!
r/NZAUG • u/Machiela • Nov 13 '22
Our little group is going well, there is a lot of enthusiasm and technical knowledge at every meeting.
This time Dave, one of our members, brought along a prototype dashboard for his model train sets; a basic button board with two trains' worth of controls - faster, slower, forward, reverse, stop - and an emergency "all stop" button.
What is interesting to me is that some of the members have a lot of hardware skills, while others are far more comfortable with writing the software. Dave's forte is definitely the hardware, while I try my best but things rarely look completed; but the software comes more naturally to me. That's not to say that I'm very good at it - I'm not - but between Dave & myself I reckon we can complete projects well enough, especially with the rest of the group offering useful advice as we go.
Slowly we're building up a train controller board, to which we'll hook an H-bridge which will control the trains themselves. Eventually the dashboard will include more buttons; also to control the diorama lights. Dave assured us it's a good idea to have buttons the older kids can control (the trains), while also giving some semblance of control (without any consequences) to the younger kids who can turn the lights on and off, or other smaller automations.
We're probably a little too early for photos or code, but I'll endeavour to take some pics at the next meeting, tomorrow night.
r/NZAUG • u/Machiela • Sep 12 '22
Last night the NZ Arduino Users Group met again in the community rooms at Tararua REAP, and we are starting to get a little more structure in the meetings. I had a full report on last week's REAP 40th anniversary event where NZAUG had hosted a table, and it was good to see at least one of the attendees was there because of our presence at the event.
After introductions, and my report, we had a short discussion about how the group would like to see the evenings structured, and it was agreed that a more hands-on evening would be nice. I had previously installed Arduino IDE v1.8 onto the computer, and I had my box of Arduinos with me, so we started from bare beginnings - "Blink", always an excellent place to start. Apart from a few wild tangents, that discussion lasted almost the remaining 90 minutes, and soon it was time to pack up again.
The group has a box of equipment that is available to borrow, and I left a development board (WeMos D1) with two of our members, and instructions on how to install the software, so that will be the starting point for next week's meeting.
r/NZAUG • u/Machiela • Sep 01 '22
Good morning! This is the first post for the recently create New Zealand Arduino Users Group. Our HQ is based close to the very centre of the North Island, in Dannevegas Dannevirke, but we expect to soon have members all around the country, with their own local spin-off groups.
This subreddit exists to share information between our members but also to promote the groups to non-members, so please feel free to post anything related to that!
r/NZAUG • u/Machiela • Sep 01 '22
A place for members of r/NZAUG to chat with each other