LOCODUINO

Aide
Forum de discussion
Dépôt GIT Locoduino
Flux RSS

mardi 19 mars 2024

Visiteurs connectés : 38

Un décodeur d’accessoires universel (3)

. Par : Thierry

Résumé des épisodes précédents... Universal Accessory Decoder, UAD pour les amis, est une bibliothèque destinée à piloter des accessoires via des circuits de puissances commandés par un Arduino. Les ordres peuvent être reçus par des codes DCC en écoutant les rails, ou par des boutons à actionner manuellement, comme un TCO (Tableau de (...)

Retourner à l'article

Vous répondez à :

Un décodeur d’accessoire universel (3) 16 octobre 2015 10:54, par Thierry

Je dirais quelque chose comme ça (compilé mais pas testé !)

/*************************************************************
project: <DCC Accessory Decoder>
author: <Thierry PARIS>
description: <Test for UAD library, with one light, controled by Dcc.>
*************************************************************/

#include "UniversalAccessoryDecoder.h"

/* kDCC_INTERRUPT values :
Board         int.0   int.1   int.2   int.3   int.4   int.5
Uno, Ethernet   2      3
Mega2560        2      3      21      20      19      18
Leonardo        3      2      0       1       7
*/
#define kDCC_INTERRUPT          5

// Accessories

Accessories accessories;
DccCommander dccCommander;

// Drivers
	
DriverArduino *arduino;

//////////////////////////////////
//
// Setup
//
void setup()
{
	UAD_StartSetup();

    // Setup of the Dcc commander.
	dccCommander.Setup(0x00, 0x00, kDCC_INTERRUPT);
	dccCommander.SetStatusLedPin(13);

	// Drivers setups

    // one light is connected to the arduino.
	arduino = new DriverArduino(1, 0); // 1 motor/led, 0 servos
	arduino->Setup();
	arduino->SetupPortMotor(0, 13); // first port (0), pin 13
	
	// Accessories setups

    // Assign Dcc code for each accessory.
	accessories.Setup(1);
	accessories.Add(new AccessoryLight(1, 0)); // dcc 1/0

   // Attach each accessory to its driver/port.
	LIGHT(accessories, 0)->Setup(arduino, 0); // use port 0 of arduino driver

	UAD_EndSetup();
}

void loop()
{
    // Dcc is run first, and if necessary, lets the accessories work.
	if (dccCommander.Loop())
	{
		accessories.Loop();
	}
}
Qui êtes-vous ?
Votre message

Pour créer des paragraphes, laissez simplement des lignes vides.

Lien hypertexte

(Si votre message se réfère à un article publié sur le Web, ou à une page fournissant plus d’informations, vous pouvez indiquer ci-après le titre de la page et son adresse.)

31 Messages

Rubrique Bibliothèques

Bibliothèque Accessories (1)

Bibliothèque Accessories (2)

Un décodeur d’accessoires universel (1)

Un décodeur d’accessoires universel (2)

Un décodeur d’accessoires universel (3)

Bibliothèque LcdUi (1)

Bibliothèque LcdUi (2)

La bibliothèque Servo

Bibliothèque SoftWare Serial

Bibliothèque Serial

Bibliothèque EEPROM

Bibliothèque Wire : I2C

Bibliothèque LCD

La bibliothèque ScheduleTable

Bibliothèque MemoryUsage

Bibliothèque EEPROMextent

La bibliothèque SlowMotionServo

Bibliothèque Commanders

Bibliothèque DCCpp

Bibliothèque DcDccNanoController

La bibliothèque ACAN (1)

La bibliothèque ACAN (2)

Bibliothèque LightEffect

Les derniers articles

Bibliothèque LightEffect


Christian

La bibliothèque ACAN (2)


Jean-Luc

La bibliothèque ACAN (1)


Jean-Luc

La bibliothèque SlowMotionServo


Jean-Luc

Bibliothèque DCCpp


Thierry

Bibliothèque DcDccNanoController


Thierry

Bibliothèque LcdUi (2)


Thierry

Bibliothèque LcdUi (1)


Thierry

Bibliothèque Accessories (2)


Thierry

Bibliothèque Accessories (1)


Thierry

Les articles les plus lus

Bibliothèque Wire : I2C

La bibliothèque Servo

Bibliothèque SoftWare Serial

Bibliothèque DCCpp

La bibliothèque ACAN (1)

La bibliothèque SlowMotionServo

Bibliothèque EEPROM

Bibliothèque LCD

Un décodeur d’accessoires universel (3)

Bibliothèque DcDccNanoController