Difference between revisions of "Lego Technic of the Past Arduino Library"

From LVL1
Jump to navigation Jump to search
Line 2: Line 2:
 
<code>
 
<code>
  
/*
 
LegoTechnic.h - Library to run Lego Technic Controller brick with a specific Arduino Shield.
 
Created November 16, 2015
 
Rights Reserved
 
*/
 
#ifndef LegoTechnic_h
 
#define LegoTechnic_h
 
  
 
+
class LegoTechnic
#include "Arduino.h"
+
{
 +
  public:
  
 
#define PORT0_PIN 3
 
#define PORT0_PIN 3
Line 31: Line 25:
 
#define COMBO_BOTH 3
 
#define COMBO_BOTH 3
  
class LegoTechnic
 
{
 
  public:
 
 
     LegoTechnic();
 
     LegoTechnic();
 
     LegoTechnic(int P0, int P1, int P2, int P3, int P4, int P5, int P6, int P7);
 
     LegoTechnic(int P0, int P1, int P2, int P3, int P4, int P5, int P6, int P7);
Line 58: Line 49:
 
};
 
};
  
#endif
 
  
  
 
</code>
 
</code>

Revision as of 21:45, 16 November 2015

HEADER


class LegoTechnic {

 public:
  1. define PORT0_PIN 3
  2. define PORT1_PIN 5
  3. define PORT2_PIN 6
  4. define PORT3_PIN 9
  5. define PORT4_PIN 10
  6. define PORT5_PIN 11
  1. define PORT6_ANALOGPIN 0
  2. define PORT7_ANALOGPIN 1
  1. define PORT_ON HIGH
  2. define PORT_OFF LOW
  1. define COMBO_OFF 0
  2. define COMBO_LEFT 1
  3. define COMBO_RIGHT 2
  4. 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[6] = {255, 255, 255, 255, 255, 255};
   void Verbose(int value);
   void Parse_Command(String Command);
 private:
   int _D0,_D1,_D2,_D3,_D4,_D5,_A6,_A7;
   int _Verbose = HIGH;
   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();

};