Archive

Archive for the ‘Trinket Projects’ Category

Arduino Sketch upload via Bluetooth

October 5, 2016 Leave a comment

After a Smart Robot Kit assembly :

ROBOT_Assembly (1).jpg

Start looking for a way to upload Sketches to the Arduino  wirelessly.

After some Internet searching… decided to go deeper and understand how the HC-06 Bluetooth module works and how is the upload process.

In the HC-06, the STATUS signal indicates when a Bluetooth bind condition is established.

After look at the signal,  the first idea was to use an LM555 as a resettable monostable multivibrator… ok,  an 8 pin DIP IC and several passive components….

Then why no use an ATTINY85 to do the work?

Here is the proof of concept using an Adafruit’s TRINKET 3.3V.

blue_remoteprogramming


The TRIKET checks the behavior of the STATE signal to identify the bind condition and generates the RESET pulse.

bluetooth_hc-05_status

 

Test made with an Arduino NANO clone:

wireless_sketch_upload

Testing Arduino Duemilanove (same HC-06 configuration, 57600 bauds):

BT_RemoteProg.jpg


The Sketch used in the TRINKET:

/*Trinket_BlueReset.ino   Arduining 4 OCT 2016
 Using TRINKET to generate the RESET for Remote Arduino Programming.
 
 -HC-06 BlueTooth Module as Slave 115200 bauds (UNO, Optiboot loader) 
 -HC-06 BlueTooth Module as Slave 57600 bauds (Duemilanove, NANO)
 -Using the STATUS pin of The HC-06 to identify a Binded condition.
 -The TRINKET LED (pin 1) show the Bluetooth condition:
          5 Hz Not Binded, 1 Hz Binded.

 -STATPIN is the STATUS signal from HC-06 (pin 24).
 -RESETPIN is the RESET signal to start the bootloader in the Arduino.
             |<--200mSeg-->|             |<120mSeg>|
              ______        ______        _______________________________
   STATPIN __|      |______|      |______|
           --------------  Not Binded ------------>|<----- Binded -------
            _______________________________________ _____________________
   RESETPIN                                        |


  -If no changes in STATPIN for 120 milliseconds a RESETPIN pulse is generated.

                           __,-----,__
                          |[]|_____|[]|<===LED
   [----- (4.3-16)V ----->|o         o|[---- +USB(+5V 500mA) ---->
   <-------- GND -------->|o         o|<PB0>-<0>-[0A>-<SDA>-[MOSI>  ==> RESETPIN
   USB-<4A]-[A4>-<4>-<PB4>|o TRINKET o|<PB1>-<1>-[1A>-------<MISO]-LED>
   USB------[A3>-<3>-<PB3>|o         o|<PB2>-<2>-<A1]-[SCL>-[SCK >  <== STATPIN
   [-------- RESET------->|o         o|+3.3V(150mA)Reg. from BAT->
                          |   [( )] __|
                           \_______/
                  Trinket (3.3V) Pinout Diagram  

 -----------------------------------------------------------------------------*/

#define LEDPIN     1               // LED PIN for signaling.
#define RESETPIN   0               // Attached to the RESET pin of the Arduino.
#define STATPIN    2               // Attached to the STATUS pin of the HC-06
volatile bool flag= false;
int pulseTimer= 120;               // Waiting time for pulses in STATPIN (mSeg)

/*------------------------------------------------------------------------------
  setup()
------------------------------------------------------------------------------*/
void setup(){
    GIMSK = 0b00100000;            // turns on pin change interrupts
//    PCMSK = 0b00010011;          // turn on interrupts on pins PB0, PB1, & PB4
    PCMSK = 0b00000100;            // turn on interrupts on pin 2 (PB2)
    sei();                         // enables interrupts
    
    pinMode(LEDPIN, OUTPUT);    
    pinMode(RESETPIN, OUTPUT);
    pinMode(STATPIN, INPUT_PULLUP);
    digitalWrite(RESETPIN, HIGH);  // Set RESET to High.  
}

/*------------------------------------------------------------------------------
  loop()
------------------------------------------------------------------------------*/
void loop(){
  delay(1);

	if(flag){
    pulseTimer=120;                // Reset waiting time for pulses in STATPIN.
    flag = false;
	}
  else pulseTimer--;
  
	if(pulseTimer == 0){
    //Here we can check for a '0' in the serial channel (57600 bauds).
	  digitalWrite(RESETPIN, LOW);   // Produce a RESET pulse of 1 millisecond.
    delay(1);
    digitalWrite(RESETPIN, HIGH);  // Return to High.
    
    while(!flag){
      digitalWrite(LEDPIN,LOW);
      delay(500);
      digitalWrite(LEDPIN,HIGH);
      delay(500);          
      }                            // Hold until next Binding.
	}

}

/*------------------------------------------------------------------------------
  Pin Change Interrupt of pin 2 (PB2).
------------------------------------------------------------------------------*/
ISR(PCINT0_vect){
    flag = true;                   // signals the change in pin 2.
    digitalWrite(LEDPIN,digitalRead(STATPIN));   //Signaling the HC-06 STATUS.
    sei();                         // enables interrupts
}


 

If the Arduino to be programmed works with 3.3V the wiring is simpler:

arduino3v3_remoteprogr

Now we can program the Arduino without the USB cable. Also we can control the robot remotely via Bluetooth, just remember to use  Serial.begin(57600) in your control program  ….

Any additional ideas will be appreciated,

Thanks for visiting this blog.

Interrupts with the TRINKET analog comparator

July 12, 2015 Leave a comment

Here I’m sharing a working example using the analog comparator of the Adafruit’s  TRINKET (ATtiny85).

Trinket_ISR

 

/*Trinket_comp_ISR.ino  Arduining.com 12 JUL 2015
  Sketch to test interrupts fron the analog comparator.
  2.5 Volt in ANI0 (voltage divider).
  Potentiometer input in ANI1  An interrupt is generated in every change of the comparator output (toggle).
  The interrupt set the flag  "triggered".
  The main loop program checks for the flag, if the flag is set, test the output value  of the comparator
  and modify the state of the LED according.*/

#define LED 4 

volatile boolean triggered=false;

//------------ Analog Comparator Interrupt Routine ----------------------------
ISR(ANA_COMP_vect){  
  triggered = true;
}
  
//-----------------------------------------------------------------------------
void setup(){
 pinMode(LED,OUTPUT);
  ADCSRB &= ~(1<<ACME);             //Set AIN1 as the negative input (Potentiometer).
  DIDR0 |= (1<<AIN1D)|(1<<AIN0D);   // disable digital inputs.
  
//ACSR – Analog Comparator Control and Status Register   
  ACSR = B00001000; // comparator interrupt enabled and tripped on toggle. (compare with AN1)
      //  ||||||||_ ACIS0 ACIS1, ACIS0: Analog Comparator Interrupt Mode Select
      //  |||||||__ ACIS1 10= falling edge; 11= raising edge; 00= toggle.
      //  ||||||___ ACIC  Reserved Bit
      //  |||||____ ACIE  Interrupt Enable
      //  ||||_____ ACI   Analog Comparator Interrupt Flag (R/W), write 1 to clear it.
      //  |||______ ACO   Analog Comparator Output (read only)
      //  ||_______ ACBG  1= Bandgap Select (1.1V); 0= compare with AIN0 (pin 6)
      //  |________ ACD   Analog Comparator Disable


  digitalWrite(LED, HIGH);//LED on for 100 milliseconds.
  delay(100);
  //Put the LED status as the analog comparator output (inverted)
  if(ACSR & (1<<ACO))digitalWrite(LED, LOW);
  else digitalWrite(LED, HIGH);
}

//-----------------------------------------------------------------------------
void loop(){
  if(triggered){
    if(ACSR & (1<<ACO))digitalWrite(LED, LOW);
    else digitalWrite(LED, HIGH);
    triggered= false;
    //while(1){}
  }
}


Arduino Pro Trinket Pinout Diagram

April 2, 2015 Leave a comment

Here is my quick reference to wire the Adafruit’s Pro Trinket.

Following the color sheme of the previous published Trinket pinout diagram.

https://arduining.com/2014/01/30/arduino-trinket-pin-diagram/

Pro_Trinket_pins_01

Pins A0-A5 can also be named as 14-19 for digital I/O ( digitalRead() and digitalWrite() ).


Very handy arduinos…

Four_Pro_trinkets

I’ll be posting some project with them…

My first approach was making a Christmas tree star, using Neopixels, last December…

B50LQdFIUAApVGn

Mini Client with the Arduino TRINKET and the ESP8266

January 19, 2015 14 comments

ending the temperature to a ThingSpeak channel using the TMP35 sensor.

This is a small and low cost implementation of IoT (Internet of Things, possibly one of the next technological revolutions). Mini-Client-Trinket-ThingSpeak The ESP8266 can be used alone thanks to the apparition of several environments like LUA, C, Micro Python etc.. In this case I wanted to keep the solution in the Arduino environment to take advantage of many ready-to-use libraries and examples. Then I realized, due the reduced space in the Trinket (5.310Kb for code), the usability of such libraries it’s not so simple. Programming the ATtiny85 with an ISP programmer will permit the use of the full 8K programming memory. Anyway was a fun project, is great to see the small ATtiny85 acting as a Web Client. Let’s make the Trinket do the job using just the Arduino IDE.


Power considerations: The ESP8266 is power hungry when is communicating with a Wi-Fi spot. It can reach 215mA in Transmit Mode. The 3.3Vregulator in the Trinket only supply 150mA max. Then we need to use another 3.3V power source. The L4931 (250 mA) is working at first. A 470 uF capacitors is needed at the output.


Wiring diagram: (….. on the works)


Making the ESP8266 breadboard friendly:  To modify the ESP8266 we need a 0.1″ 4-pin right-angle male header. The procedure is very simple:ESP8266-breadboard-09 First cut (remove) the row of pines closer to the board border. Then, using a breadboard as guide and support, sold the right-angle header. Use enough solder to obtain a good mechanical resistance.     More images in this post: https://arduining.com/2015/01/02/making-esp8266-breadboard-frienly/


Mini breadboard wiring:

MiniClient_wiring

Wire color identification:

Black: ground.

Red: +5V.

Orange: 3.3V from the L4931 regulator.

Yellow: Trinket RX data (ESP8266 TX).

Purple: Trinket TX data (ESP8266 RX).

Blue: ESP8266 reset.

Green: Trinket analog input (TMP36 Vout).


Final assembly:

MiniClient_assembled

Everything in it’s place… let’s coding…


Temperature Sensor TMP35: TMP35_chart


The Trinket Sketch: At first, just ported the code from a working example made with the Meduino NANO and the DHT22 temperature sensor, finding out that the code size will be a problem. open-style-packaging-2


Several changes were implemented to reduce the code size: Changing to the TMP35 temperature sensor because is easier to read (don’t need a library ). Avoiding the use of string manipulation functions. Avoiding the use of floating math operations. (Only integer math was used). Integrating CR and LF at the end of the strings and using print() function instead of println(). Many other changes until the compiler of the Arduino IDE announced:

Binary sketch size: 4,748 bytes (of a 5,310 byte maximum)


The Sketch:

/*ESP8266_Trinket_01.ino Arduining.com (29 APR 2015)
Sending temperature data to ThingSpeak.
Hardware:
 -Adafruit's Arduino Trinket (3.3V)
 -ESP8266(ESP-01)
 -Temperature sensor TMP35

Data update rate set by the SPERIOD value.
Using SoftwareSerial at 9600 bauds.
String and math functions avoided.
The temperature is not calibrated.
  -ATtiny85 internal reference differs a little from 1.1V
  -The TMP35 is affected by radio frequencies.

Sketch uses 4,748 bytes (89%) of program storage space. Maximum is 5,310 bytes.
-----------------------------------------------------------------------------*/

#include <SoftwareSerial.h> 

//Network parameters and server IP address:
#define mySSID    "XXXXXXXXX"           //WiFi network ID.
#define myPASS    "XXXXXXXXX"           //Password.
#define serverIP  "184.106.153.149"     //IP of ThingSpeak.com
#define ChannKEY  "XXXXXXXXXXXXXXXX"    //ThingSpeak channel key.

#define updField  "1"                   //Updating Field( 1,2,3,4,5...)
#define SPERIOD   30000                 //Sampling period (milliseconds).
#define MAXFAILS  10                    //Number of fails to RESET the ESP8266.

//Concatenating the string messages:
#define mode_MSG  "AT+CWMODE=3\r\n"       //Dual mode (Station and Access Point).
#define join_MSG  "AT+CWJAP=\"" mySSID "\",\"" myPASS "\"\r\n"      //set data to join the AP.
#define conn_MSG  "AT+CIPSTART=\"TCP\",\"" serverIP "\",80\r\n"     //TCP, ThingSpeak, port 80.
#define send_MSG  "AT+CIPSEND=46\r\n"     //Send data, size=46 (4 bytes for the value)
#define upda_MSG  "GET /update?key=" ChannKEY "&field" updField "=" //Updating Field data.
#define clos_MSG  "AT+CIPCLOSE\r\n"       //Close TCP connection.


//Trinket pins assignament:
#define RXDATA    1      // SoftwareSerial receive pin (RED LED connected).
#define TXDATA    0      // SoftwareSerial transmit pin.
#define HRESET    3      // Pin to hardware Reset the ESP8266
#define ANATEMP   1      // Analog channel 1 for temperature measurement.

int i,j;
int fails=100;           // set failures>MAXFAILS to generate initial RESET.
unsigned int temp;       // Use positive range values (0-32768)
String tempVal="00.0";   // Four characters (fixed format number).

SoftwareSerial ESPSerial(RXDATA, TXDATA);   // Creates SoftwareSerial channel.

//====================== Setup ================================================
void setup(){
  
  analogReference(INTERNAL);        //Use the 1.1V internal reference.
  pinMode(HRESET,OUTPUT);           //hardware reset for the ESP8266.
  ESPSerial.begin(9600);
  initESP();                        // ESP8266 init.

}   //END of setup.

//====================== loop =================================================
void loop(){

  while((millis() % SPERIOD)>10){};   //Wait for the next multiple of SPERIOD.

  while(ESPSerial.read()!= -1){};     //Wait until no serial data available.

//------------- Here is the temperature reading for the TMP35 ------------------
/*-------------------------------------------------------------------
    For compactness of the code, integer math is used:
    TheTMP35 has 10 mV/°C scale factor:Temp in °C = (Vout in mV)/10 
    With Vref=1.1V the range is: 0°C to +60°C, (0.1 degree resolution)
    AnalogRead value (559) => 60 degree.
    32768/1024= 32 (maximum multiplier to keep the integer positive).
    Multiplier and divider factors are: 29/27= 1.0740 close to 1100/1024.
 --------------------------------------------------------------------*/
  temp= (analogRead(ANATEMP)* 29)/27;  //value in millivolts (1.1V internal ref.)

//------ formating the integer temp to a 4 character string ---------  
  tempVal[0]= '0'+(temp/100);
  tempVal[1]= '0'+(temp%100/10);
//  tempVal[2]= '.';   //decimal point already there.
  tempVal[3]= '0'+(temp%10);

  updateValue();
  if (fails > MAXFAILS) initESP();   //Reset and init ESP8266 after some fails.

}   // END of loop.

/*-----------------------------------------------------------------------------
Function updateValue() 
-----------------------------------------------------------------------------*/
void updateValue(){
  ESPSerial.print(conn_MSG);        //Open TCP connection with ThingSpeak.
  if(waitChar('K',10000)){          //Wait for 'K' of "OK".
    delay(250);                     //Delay to receive the message "Linked"
    ESPSerial.print(send_MSG);      //Send message AT+CIPSEND= and size.
    if(waitChar('>',10000)){        //Wait for '>'.
      ESPSerial.print(upda_MSG);    //Update Field value.
//      tempVal= "13.4";
      ESPSerial.print(tempVal);
//      ESPSerial.print("20.7");    // test value
      ESPSerial.print("\r\n");      //to replace println (less code).
      fails=0;                      // clear failure counter.
      return;                       // Unlink automatically....
    }
  }
  fails++;
  ESPSerial.print(clos_MSG);       //Close the TCP connection with ThingSpeak.  
}

/*-----------------------------------------------------------------------------
Function waitChar() 
-----------------------------------------------------------------------------*/
bool waitChar(char Wchar, int duration){
  for(i=duration;i>0;i--){
    delay(1);
    if(ESPSerial.read()== Wchar)return true;
  }
  return false;
}

/*-----------------------------------------------------------------------------
Function initESP() 
-----------------------------------------------------------------------------*/
void initESP(){
  while(1){
    if (fails > MAXFAILS){           //------Hardware reset for ESP8266.
      digitalWrite(HRESET,LOW);
      delay(100);
      digitalWrite(HRESET,HIGH);
      delay(5000);
      fails=0;
    }

    ESPSerial.print("AT\r\n");       //"\r\n" to replace println  (less code)
    delay(1000);
    if(waitChar('K',1000)){          //Wait for 'K' of "OK".
      ESPSerial.print(mode_MSG);     //Set Station mode.
      delay(250); 
      ESPSerial.print(join_MSG);     //Set name and password of the AP.
      if(waitChar('K',10000))return; //Wait for 'K' of "OK" to exit setup
    }
    fails++;
  }

}


Mini Client part list :

Adafruit-Part-List

Pictures from the Adafruit Industries web page.

1.- USB cable – A/MiniB. (1)
2.- Hook-up Wire 22AWG Solid Core (assorted colors) .(1)
3.- Tiny breadboard 170 contacts. (1)
4.- Adafruit’s Trinket – Mini Microcontroller – 3.3V Logic. (1)
5.- 3.3V 250mA Linear Voltage Regulator – L4931-3.3 TO-92. (1)
6.- 10uF 25V Electrolytic Capacitor. (1)
7.- 470uF 25V Electrolytic Capacitor. (1)
8.-TMP35 – Analog Temperature sensor. (1)
9.- ESP8266 WiFi Module. (1)

NOTE: A 0.1″ 4-pin right-angle male header is recommended to adapt the ESP8266 to the breadboard.


This Post Is Under Construction…

28 APR 2015 : New wiring,  Sketch posted.

… More info when requested and (or) available.

Thanks for reading.


Arduino Trinket Photo Session

February 19, 2014 1 comment

After receiving a bunch of Trinkets, my first impulse was to do some photographic composition…

AtHand

TrinketHandIntelligence at your fingertips.

Trinket_Photo_01Imagine what can be done…

roundGoing arround…

NestTrinketsTrinket nest…

man_002Distributed intelligence…

ArduinoTrinketsGo arduining…

Arduino Trinket and Serial LCD

February 17, 2014 2 comments

Testing the bit bang serial transmission to connect the Trinket with the Serial LCD Module 16×2 from NKC Electronics.
The first Sketch with string functions use 3,634 bytes, the second Sketch, avoiding string functions, use 1,362 bytes.

20140217_125246

Sketch with string functions:

/*	Test_LCD.ino
	Arduining.com  16 FEB 2014
	Binary sketch size: 3,634 bytes (of a 5,310 byte maximum)

	A timer is implemented presenting minutes and seconds elapsed since start.
	Bit Banging Serial transmission at 9600 bauds.
	Example using the Trinket from Adafruit (5V, 8 Mhz)
	and Serial LCD Module 16x2 from NKC Electronics.
*/

//----- defining bit banging serial values:------------------------------------
#define	TXDATA    1         // Pin used to transmit data.
#define BITTIME   93        // Adjusted with osciloscope to obtain 9600 bauds.

//----------variables:---------------------------------------------------------
int 	seconds= 0;		//seconds counter
String 	number;			//String to be sent to the display.
//=============================================================================
void setup() {                
	pinMode(TXDATA, OUTPUT);   // initialize the TXDATA pin as an output.
	digitalWrite(TXDATA,HIGH); // TXDATA = 5V when is resting.
//---LCD Display initialisation---
	delay(500);
	sendChar(0xFE);
	sendChar(0x41);		//display on.
	sendChar(0xFE);
	sendChar(0x51);		//clear display.
	sendChar(0xFE);
	sendChar(0x4C);		//cursor blinking Off.
	sendChar(0xFE);
	sendChar(0x48);		//cursor Off.
	sendChar(0xFE);
	sendChar(0x46);		//cursor at home.
	sendChar(0xFE);
	sendChar(0x53);		//backlight brightness command.
	sendChar(4);		//brightness 1-8
	sendChar(0xFE);
	sendChar(0x52);		//contrast command.
	sendChar(45);		//contrast 1-50
	show(" Arduining.com");
}

//================= Main loop =================================================
void loop() {
	if ((millis() % 1000)<2){ 				//Skip until the next second.

		sendChar(0xFE);
		sendChar(0x45);						// Set cursor at
		sendChar(0x45);						// line 2 pos 6

		number = String (seconds/60);		//elapsed minutes
		while(number.length()<2)number= "0" + number;   //format to 2 characters.
		show(number); 						//Show minutes in the display

		sendChar(':');

		number = String (seconds % 60);		//elapsed seconds
		while(number.length()<2)number= "0" + number;   //format to 2 characters.
		show(number); 						//Show seconds in the display

   		seconds++;
   		if (seconds >= 3600) seconds=0;		//roll over
	}
}

//-----------------------------------------------------------------------------
void sendChar(char c){
	delayMicroseconds(BITTIME*2);          		// wait 2 Stop bits.
	digitalWrite(TXDATA,LOW);              		// TXDATA=0.
	delayMicroseconds(BITTIME);            		// wait Start bit.
	for (int i=0; i<8;i++){
		digitalWrite(TXDATA,bitRead(c, i)); 	// bit out.
		delayMicroseconds(BITTIME);          	// wait bit
	}
	digitalWrite(TXDATA,HIGH);            		//TXDATA=1.
}

//-----------------------------------------------------------------------------
void show(String s){
	int lenght=s.length();
	for(int i=0;i<lenght;i++){
	sendChar(s[i]);
	}
}

Sketch without string functions:

/*	Test_LCD_01.ino
	Arduining.com  17 FEB 2014
	Based in Test_LCD.ino (2,278 bytes less avoiding string functions).
	Binary sketch size: 1,356 bytes (of a 5,310 byte maximum)

	A timer is implemented presenting minutes and seconds elapsed since start.
	Bit Banging Serial transmission at 9600 bauds.
	Example using the Trinket from Adafruit (5V, 8 Mhz)
	and Serial LCD Module 16x2 from NKC Electronics.
*/

//----- defining bit banging serial values:------------------------------------
#define	TXDATA    1         // Pin used to transmit data.
#define BITTIME   93        // Adjusted with osciloscope to obtain 9600 bauds.

//----------variables:---------------------------------------------------------
int 	seconds= 0;		//seconds counter
//=============================================================================
void setup() {                
	pinMode(TXDATA, OUTPUT);   // initialize the TXDATA pin as an output.
	digitalWrite(TXDATA,HIGH); // TXDATA = 5V when is resting.
//---LCD Display initialisation---
	delay(500);
	sendChar(0xFE);
	sendChar(0x41);		//display on.
	sendChar(0xFE);
	sendChar(0x51);		//clear display.
	sendChar(0xFE);
	sendChar(0x4C);		//cursor blinking Off.
	sendChar(0xFE);
	sendChar(0x48);		//cursor Off.
	sendChar(0xFE);
	sendChar(0x46);		//cursor at home.
	sendChar(0xFE);
	sendChar(0x53);		//backlight brightness command.
	sendChar(4);		//brightness 1-8
	sendChar(0xFE);
	sendChar(0x52);		//contrast command.
	sendChar(45);		//contrast 1-50
	show(" Arduining.com");
}

//================= Main loop =================================================
void loop() {
	if ((millis() % 1000)<2){ 				//Skip until the next second.

		sendChar(0xFE);
		sendChar(0x45);						// Set cursor at
		sendChar(0x45);						// line 2 pos 6

		sendChar((seconds/600)+'0');		//show tens of minutes 
		sendChar(((seconds/60) % 10)+'0');	//show units of minutes
		sendChar(':');
		sendChar(((seconds % 60)/10)+'0');	//show tens of seconds
		sendChar((seconds % 10)+'0');		//show units of seconds
   		seconds++;
   		if (seconds >= 3600) seconds=0;		//roll over
	}
}

//-----------------------------------------------------------------------------
void sendChar(char c){
	delayMicroseconds(BITTIME*2);          		// wait 2 Stop bits.
	digitalWrite(TXDATA,LOW);              		// TXDATA=0.
	delayMicroseconds(BITTIME);            		// wait Start bit.
	for (int i=0; i<8;i++){
		digitalWrite(TXDATA,bitRead(c, i)); 	// bit out.
		delayMicroseconds(BITTIME);          	// wait bit
	}
	digitalWrite(TXDATA,HIGH);            		//TXDATA=1.
}

//-----------------------------------------------------------------------------
void show(char s[]){
	int i=0;
	while(s[i]!=0){					//looking for the string end.
		sendChar(s[i]);
		i++	;
	}
}

Arduino Trinket and Gauge Stepper Motor

January 31, 2014 15 comments

Driving directly a stepper motor used for Vehicle’s Instrument Gauges.

wpid-20140131_232948.jpg

The motor must be removed during the Sketch Loading (disconnect from USB pins) .

wpid-IMG_20140131_235102.jpg

This kind of motors can be driven directly by the Trinket.
The motor follows the potentiometer.

IMG_0009

The Sketch is the same used in the “Arduino Driving a Micro Stepper Motor” in this blog, just change the pin mapping to use the Trinket .

https://arduining.com/2012/04/22/arduino-driving-a-micro-stepper-motor/

Change the definitions in “Gauge_Pot01.ino”:

#define  STEPS  720    // steps per revolution (limited to 315°)
#define COIL1  1
#define COIL2  3
#define COIL3  4
#define COIL4  0
#define POTIN  1

The YouTube video…