Close
0%
0%

Example ATTiny10-Solo Sketches from CanHobby

Documented Sketches for my Tiny10-SOLO YouTube Video.

Public Chat
Similar projects worth following
Example sketches for the ATTiny10-Solo from CanHobby.ca

The CanHobby ATTiny10-Solo is a minimal development board for the ATtiny10 MCU from MicroChip.  It is designed to be used on a breadboard and has no on-board LED.

Everyone knows how to write a simple Arduino sketch but the ATTiny10 is a little different.  Due to it's limited SRAM and Flash memory, conventions such as digitalWrite() do not exist.  This sketch will illustrate the use of "Register Programming" which is at a lower level, just one step above assembler.

The source code and required Boards Package used in this example are listed in the Instructions.

 I plan to include several different sketches highlighting different peripherals featured by the ATtiny10 MCU. The most important sketch presented here is a ATtiny DEBUG Display to make code development and debug easier.  This becomes even more important when one keeps in mind the lack of a serial port on these Tiny MCUs.

"DEBUG display" details:

The DEBUG display uses an eight digit 7 segment LED display available from many sources including CanHobby and AliExpress. It has a pseudo SPI interface using a MAX7219 for which this sketch provides a simple bit-banged driver. Although it uses 3 pins to connect any interference with the operation of other modules that you may have connected can normally be compensated for in the sketch.

The display connections are as follows:

    Vcc --> +3.3V or +5V

   Gnd --> 0V

   MAX7219_DIN  -->  B0
   MAX7219_CS   -->  B1
   MAX7219_CLK -->  B2

The simple bit-banged driver provides 5 methods:

  •  Seg7_hex( uint8_t hex_number, uint8_t position ) - where "hex_number" is the 0x00-0xFF hex number to display, and position is the starting LED position to display the 2 digit hex number. Position 0 starts from the left.
  • Seg7_dec2(  uint8_t dec_num, uint8_t position ) - where "dec_number" is the 0-99 decimal number to
    display, and position is the starting LED position to display the 2 digit decimal number. Position 0 starts from the left.
  • Seg7_clear( uint8_t position ) - is used to clear the display starting from the indicated position.
  • Seg7_dec(  uint16_t dec_num, uint8_t position ) to display a 4 digit decimal number exists but has not been tested.
  • Seg7_init()  initializes the 7 segment display.

Sketch Overview:

The ADC_7Seg.ino sketch serves 2 functions.

  1. Using the Debug Display.
  2. Using the ADC (analog to digital converter) on the RESET pin.

It is very simple - in setup() we initialize the ADC on pin B3 and then initialize the Seg7 debug display and clear it.  In the loop() we read the ADC value and display it on the debug display, wait 2 seconds, and repeat.

Setup Code:

#include <util delay.h>    // this is for the delay_ms() function.
#include "Seg7.h"          // this is my Seg7 driver.

#define ADC3  3            // we will be using ADC # 3 which is on B3

void setup() {

  ADMUX  |= ADC3;            // we will use ADC3
  ADCSRA  = 1<<ADEN | 3<<ADPS0;  // Enable ADC, 125kHz clock

  Seg7_init();   //  this will set B0, B1, B2 to OUTPUT for both the Seg7 and the 74HC595

  DIDR0 = 0x08;  //  Disable GPIO functions on B3 - RST/ADC3

  Seg7_clear( 0 );  // Clear the Seg7 display starting at position 0

}

Loop Code:

void loop() {

  ADCSRA = ADCSRA | 1<<ADSC;  // Start ADC
  while (ADCSRA & 1<<ADSC);   // Wait while conversion in progress
   _delay_ms( 4 );

 d = ( ADCL );  // get the ADC reading into a variable

 Seg7_hex( d, 1 );    // display the ADC value at position 1 of the debug.
_delay_ms( 2000 );

}

Grasp the thermistor between your fingers - you should see the reading go up.

This is a very simplified example but illustrated how to use the ADC and show the value on the debug...

Read more »

Seg7_ADC.ino

Example ADC sketch using Debug Display.

x-arduino - 1.30 kB - 06/10/2024 at 10:02

Download

Seg7_Tiny10.ino

Debug Display driver.

x-arduino - 2.55 kB - 06/10/2024 at 10:02

Download

Seg7.h

defines for the Debug Display driver.

x-chdr - 2.94 kB - 06/10/2024 at 10:01

Download

  • 1 × 100K Thermistor.
  • 1 × 100K resistor.
  • 1 × 8 digit 7 segment display with MAX7219 controller.
  • 2 × GL5516 LDR.

  • 1
    Get the Arduino Sketch files.

    For use with the Arduino IDE ( I used ver. 1.8.10 ) create a directory called Seg7_ADC in your Arduino directory.

    Download all three files in the Files section of this blog into the directory you just created.

  • 2
    Add this url into the Additional Boards Manager URLs in the Preferences dialog box.
    http://www.technoblogy.com/package_technoblogy_index.json

View all instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates