element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
NexGen Flight Simuator Nexgen: CANaerospace: RSS: C-3436A Radio: Build v: - Arduino Code Base
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: phoenixcomm
  • Date Created: 27 Jun 2022 5:23 PM Date Created
  • Views 350 views
  • Likes 3 likes
  • Comments 0 comments
  • arduino mega 2560
  • nexgen_flight_simulator
  • software
Related
Recommended

Nexgen: CANaerospace: RSS: C-3436A Radio: Build v: - Arduino Code Base

phoenixcomm
phoenixcomm
27 Jun 2022

Well here is my Code Base without the Can I/O section:image

C-3436.ino C-3436.h

/*
* C-3436A.ino
*
* C. Harrison Aug 21, 2014 Creation
* Sept 17, 2021 modified
*/

#include "C3436.h"
int OLDchanLow = 0;
int OLDchanHigh = 0;
void setup(){

}

void loop(){
// Read High Frequency Contacts

for (byte hcount = 5; hcount < 10; hcount++) {
hund[hcount] = digitalRead( pins[hcount] );}
htest = calc_H();

//Get Channel info
chanLow = calc_F();
chanHigh = calc_H();

// to send data or not
if(( OLDchanLow != chanLow ) || ( OLDchanHigh != chanHigh )) {
//do output
int TPrint = 1;
if( TPrint == 1 ) {
int ncount;
//Write one line at a time: in this format count:n:n:n:....\n
Serial.print(ncount); // prints line number
Serial.print("-");
Serial.print(":");
Serial.print("-");
Serial.write(chanHigh);
Serial.print(":");
Serial.write(chanLow);
Serial.print("\n"); //Write one line at a time: in this format count:n:n:n:....\n
}
}
/* TESTprint */


} // end of loop()

// Tests and other things

byte calc_F(){
int temp = ( frac[0] + ( frac[1]*2) + ( frac[2]) + ( frac[3]*8) + ( frac[4]*16));
return( temp );
}

byte calc_H(){
int temp = (( hund[5] + hund[6]*2) + (hund[7]*4) + (hund[8]*8) + (hund[9]*16));
return( temp );
}

byte Ltest() {
byte i;
for ( i = 0; i < 10; i++ ){
if ( ftest == Lcode [i] ){
break;}
else continue; }
return( i ); }

byte Htest() {
byte i;
for ( i = 0; i < 20; i++ ){
if ( htest == Hcode[i][0] ){
break;}
else continue; }
return( Hcode[i][1]); }

/*
* C-3436A.h
*
* C. Harrison Aug 21, 2014 Creation
* Sept 17, 2021 modified
*/

// for print testing we must define TESTprint =1

// we need to list the digital input pins:

// Pin defs

// please note: arrays F[] & H[] are being indexed 0-5

int F[]= { 22, 23, 24, 25, 26 };

int H[]= { 27, 28, 29, 30, 31 };

int powerPin = 39;
int dialLight = 40;
// now we need the variables & arrays

int frac[5];
int hund[5];

int pwr, pwr0;
byte ftest;
byte htest;

int pins[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31};


// High & Low bit patterns {16, 8, 4, 2, 0} // max number = 31

// I will do the convertions staticly now

int lowBits[10][5]= {{1,1,0,1,0},{1,0,0,0,1},{0,1,0,0,0},{0,0,1,0,0},{0,0,0,1,0},

{1,0,0,0,0},{0,0,0,0,1},{0,1,0,0,1},{0,1,1,0,0},{0,0,1,1,0}};

byte Lcode []= { 26, 17, 8, 4, 2, 16, 1, 9, 12, 6 };

int highBits[20][5] = {{1,1,0,0,1},{1,1,0,0,0},{1,1,1,0,0},{1,0,0,0,1},{1,1,1,1,0},

{0,0,0,1,0},{0,1,1,1,1},{0,0,1,0,0},{1,0,1,1,1},{0,1,0,0,0},

{0,0,0,1,1},{1,0,0,0,0},{1,0,1,0,1},{0,0,0,0,1},{0,0,1,1,0},

{0,1,0,1,1},{0,0,1,0,1},{0,0,1,1,0},{1,0,0,1,0},{0,1,1,0,0}};

byte Hcode[][2]= {{13, 0}, {20, 108},{28, 109},{17, 110},{30,111},

{2, 112},{15, 113},{4, 114},{23, 115},{8, 116},

{3, 117},{16, 118},{17, 119},{1, 120},{6, 121},

{11,122},{5, 123},{6, 124},{18, 125},{12, 126}};

byte chanHigh, chanLow;

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube