tinkerkit.ino

Arduino Esplora — Board Fiche · File : tinkerkit.ino · Language : Arduino · Use case : Relier un module TinkerKit d'entrée à un module de sortie

The 3-pin TinkerKit sockets accept pre-wired DFRobot modules: potentiometer, flame sensor, LED… Here TK input A drives a PWM LED on D3, one of only two documented free output pins.

Hardware required

An Arduino Esplora (ATmega32U4, 5 V) with its onboard sensors: joystick, 4 buttons, slider, RGB LED, buzzer, light, temperature, sound and accelerometer. 1 TinkerKit input module (potentiometer) + 1 LED + 330 Ω resistor.

Wiring

TK module on socket A; LED + resistor between D3 and GND.

How it works

readTinkerkitInputA reads the multiplexer's dedicated channel; the value drives the D3 PWM pin. In the Arduino IDE, select « Arduino Esplora »; add the « Esplora » library from the Library Manager to reach the onboard sensors.

Going further

Swap the LED for a small relay (with flyback diode) to switch a mains load.

tinkerkit.ino

// Entree TinkerKit A (potentiometre TK) -> sortie PWM sur D3 (LED TK).
// Les modules TinkerKit arrivent pre-cables (signal, 5V, masse).
#include <Esplora.h>

const int SORTIE_TK = 3; // sortie libre documentee (avec D11)

void setup() {
  pinMode(SORTIE_TK, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int v = Esplora.readTinkerkitInputA(); // 0..1023 sur la prise TK A
  Serial.println(v);
  analogWrite(SORTIE_TK, map(v, 0, 1023, 0, 255));
  delay(50);
}

← Back to the board