Lego Technic of the Past Arduino Library

From LVL1
Revision as of 18:58, 17 January 2016 by JAC 101 (talk | contribs)
Jump to navigation Jump to search

LegoTechnic Header File

/* 
LegoTechnic.h - Library to run Lego Technic 70455 Controller brick with an Arduino Shield.
Created December 16, 2015
Rights Reserved
*/
#ifndef LegoTechnic_h
#define LegoTechnic_h
#include "Arduino.h"
//
class LegoTechnic
{
 public:
//
   #define PORT0_PIN 3
   #define PORT1_PIN 5
   #define PORT2_PIN 6
   #define PORT3_PIN 9
   #define PORT4_PIN 10
   #define PORT5_PIN 11
   #define PORT6_ANALOGPIN 0
   #define PORT7_ANALOGPIN 1
   #define PORT_ON HIGH
   #define PORT_OFF LOW
   #define COMBO_OFF 0
   #define COMBO_LEFT 1
   #define COMBO_RIGHT 2
   #define COMBO_BOTH 3
//
   LegoTechnic();
   LegoTechnic(int P0, int P1, int P2, int P3, int P4, int P5, int P6, int P7);
   void Output_Port(int id, int action);
   void PWM_Port(int id, int pwm_value);
   int Input_Port(int id);
   void Combo_Port(char id, int mix);
   void PWM_Combo_Port(char id, int mix, int pwm_value);
   void Port_Initialize();
   int Port_PWM_Value(int id);
   void Verbose(int value);
   void Parse_Command(String Command);
 private:
   int _D0,_D1,_D2,_D3,_D4,_D5,_A6,_A7;
   int _Verbose = HIGH;
   int _Port_PWM[6] = {0, 0, 0, 0, 0, 0};
   void _Parse_PWM_Command(String Port, String Value);
   void _Parse_Verbose_Command(String Value);
   void _Parse_CPWM_Command(String Port, String Action, String Value);
   void _Parse_Port_Command(String Port, String Action);
   void _Parse_Combo_Command(String Port, String Action);
   void _Parse_Input_Command(String Port);
   void _Display_Commands();
   void _Display_PWM_Values();
};
//
#endif


LEGO Technic Code File