<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Nextion &amp; Arduino Micro - Simhub General				            </title>
            <link>https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/</link>
            <description>All about SimHub!</description>
            <language>en-US</language>
            <lastBuildDate>Wed, 19 Aug 2026 14:15:52 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Nextion &amp; Arduino Micro</title>
                        <link>https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-6119</link>
                        <pubDate>Wed, 16 Nov 2022 12:33:10 +0000</pubDate>
                        <description><![CDATA[Hey, Im looking for your code that combined button matrix, encoders, leds and nextion, Could you share your codes?]]></description>
                        <content:encoded><![CDATA[<p>Hey, Im looking for your code that combined button matrix, encoders, leds and nextion, Could you share your codes?</p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/simhub-support/">Simhub General</category>                        <dc:creator>mckosen</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-6119</guid>
                    </item>
				                    <item>
                        <title>RE: Nextion &amp; Arduino Micro</title>
                        <link>https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-5192</link>
                        <pubDate>Mon, 06 Jun 2022 18:45:43 +0000</pubDate>
                        <description><![CDATA[@newyuk 
I&#039;m struggling to incorporate the Nextion Mirco Bridge code with code to enable buttons and rotary encoders (I have zero coding experience). Would you mind sharing how you got this...]]></description>
                        <content:encoded><![CDATA[<p>@newyuk </p>
<p>I'm struggling to incorporate the Nextion Mirco Bridge code with code to enable buttons and rotary encoders (I have zero coding experience). Would you mind sharing how you got this working? </p>
<p>Thanks in advance. </p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/simhub-support/">Simhub General</category>                        <dc:creator>Dave3520</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-5192</guid>
                    </item>
				                    <item>
                        <title>RE: Nextion &amp; Arduino Micro</title>
                        <link>https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3808</link>
                        <pubDate>Mon, 13 Dec 2021 21:12:14 +0000</pubDate>
                        <description><![CDATA[Hey.
Got it all sorted in the end.
Thanks again for your help.]]></description>
                        <content:encoded><![CDATA[<p>Hey.</p>
<p>Got it all sorted in the end.</p>
<p>Thanks again for your help.</p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/simhub-support/">Simhub General</category>                        <dc:creator>NewyUK</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3808</guid>
                    </item>
				                    <item>
                        <title>RE: Nextion &amp; Arduino Micro</title>
                        <link>https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3805</link>
                        <pubDate>Sun, 12 Dec 2021 12:17:57 +0000</pubDate>
                        <description><![CDATA[Hey
So I have the same issue of putting the two bits of code together I can make it work.
Below is the code that works for my buttons, where would I place the code you supplied?
I really ...]]></description>
                        <content:encoded><![CDATA[<p>Hey</p>
<p>So I have the same issue of putting the two bits of code together I can make it work.</p>
<p>Below is the code that works for my buttons, where would I place the code you supplied?</p>
<p>I really do appreciate your help !!!!!</p>
<p>#include &lt;Keypad.h&gt;<br />#include &lt;Joystick.h&gt;</p>
<p>//DEFINITIONS<br />#define ENABLE_PULLUPS<br />#define NUMROTARIES 3 //replace "?" with number of rotary encoders you are using<br />#define NUMBUTTONS 17 //replace "?"with number of buttong you are using<br />#define NUMROWS 5 //replace "?" with number of rows you have<br />#define NUMCOLS 4 //replace "?" with number of columns you have</p>
<p>//BUTTON MATRIX<br />//first change number of rows and columns to match your button matrix, <br />//then replace all "?" with numbers (starting from 0)<br />byte buttons = {<br />{0,1},<br />{2,3,4,5},<br />{6,7,8,9},<br />{10,11,12,13},<br />{14,15,16}<br />};</p>
<p>struct rotariesdef {<br />byte pin1;<br />byte pin2;<br />int ccwchar;<br />int cwchar;<br />volatile unsigned char state;<br />};</p>
<p>//ROTARY ENCODERS<br />//each line controls a different rotary encoder<br />//the first two numbers refer to the pins the encoder is connected to <br />//the second two are the buttons each click of the encoder wil press <br />//do NOT exceed 31 for the final button number<br />rotariesdef rotaries {<br />{A0,A1,26,27,0}, //rotary 1<br />{A2,A3,28,29,0}, //rotary 2<br />{A4,A5,30,31,0} //rotary 2</p>
<p> </p>
<p>};</p>
<p>#define DIR_CCW 0x10<br />#define DIR_CW 0x20<br />#define R_START 0x0</p>
<p>#ifdef HALF_STEP<br />#define R_CCW_BEGIN 0x1<br />#define R_CW_BEGIN 0x2<br />#define R_START_M 0x3<br />#define R_CW_BEGIN_M 0x4<br />#define R_CCW_BEGIN_M 0x5<br />const unsigned char ttable = {<br />// R_START (00)<br />{R_START_M, R_CW_BEGIN, R_CCW_BEGIN, R_START},<br />// R_CCW_BEGIN<br />{R_START_M | DIR_CCW, R_START, R_CCW_BEGIN, R_START},<br />// R_CW_BEGIN<br />{R_START_M | DIR_CW, R_CW_BEGIN, R_START, R_START},<br />// R_START_M (11)<br />{R_START_M, R_CCW_BEGIN_M, R_CW_BEGIN_M, R_START},<br />// R_CW_BEGIN_M<br />{R_START_M, R_START_M, R_CW_BEGIN_M, R_START | DIR_CW},<br />// R_CCW_BEGIN_M<br />{R_START_M, R_CCW_BEGIN_M, R_START_M, R_START | DIR_CCW},<br />};<br />#else<br />#define R_CW_FINAL 0x1<br />#define R_CW_BEGIN 0x2<br />#define R_CW_NEXT 0x3<br />#define R_CCW_BEGIN 0x4<br />#define R_CCW_FINAL 0x5<br />#define R_CCW_NEXT 0x6</p>
<p>const unsigned char ttable = {<br />// R_START<br />{R_START, R_CW_BEGIN, R_CCW_BEGIN, R_START},<br />// R_CW_FINAL<br />{R_CW_NEXT, R_START, R_CW_FINAL, R_START | DIR_CW},<br />// R_CW_BEGIN<br />{R_CW_NEXT, R_CW_BEGIN, R_START, R_START},<br />// R_CW_NEXT<br />{R_CW_NEXT, R_CW_BEGIN, R_CW_FINAL, R_START},<br />// R_CCW_BEGIN<br />{R_CCW_NEXT, R_START, R_CCW_BEGIN, R_START},<br />// R_CCW_FINAL<br />{R_CCW_NEXT, R_CCW_FINAL, R_START, R_START | DIR_CCW},<br />// R_CCW_NEXT<br />{R_CCW_NEXT, R_CCW_FINAL, R_CCW_BEGIN, R_START},<br />};<br />#endif</p>
<p>//BUTTON MATRIX PART 2<br />byte rowPins = {2,3,4,5,6}; //change "?" to the pins the rows of your button matrix are connected to<br />byte colPins = {7,8,9,10}; //change "?" to the pins the rows of your button matrix are connected to</p>
<p>Keypad buttbx = Keypad( makeKeymap(buttons), rowPins, colPins, NUMROWS, NUMCOLS);</p>
<p>//JOYSTICK SETTINGS<br />Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,<br />JOYSTICK_TYPE_JOYSTICK,<br />32, //number of buttons<br />0, //number of hat switches<br />//Set as many axis to "true" as you have potentiometers for<br />false, // y axis<br />false, // x axis<br />false, // z axis<br />false, // rx axis<br />false, // ry axis<br />false, // rz axis<br />false, // rudder<br />false, // throttle<br />false, // accelerator<br />false, // brake<br />false); // steering wheel</p>
<p>const int numReadings = 20;<br /><br />int readings; // the readings from the analog input<br />int index = 0; // the index of the current reading<br />int total = 0; // the running total<br />int currentOutputLevel = 0;</p>
<p>//POTENTIOMETERS PART 1<br />//add all the axis' which are enabled above<br />int zAxis_ = 0;<br />int RxAxis_ = 0;</p>
<p><br />//POTENTIOMETERS PART 2<br />//Which pins are your potentiometers connected to?<br />int potentiometerPin1 = 0; //Change "?" to the pin your potentiometer is connected to<br />int potentiometerPin2 = 0;<br />const bool initAutoSendState = true;<br />void setup() {<br />Joystick.begin();<br />rotary_init();<br />for (int thisReading = 0; thisReading &lt; numReadings; thisReading++) {<br />readings = 0;<br />}<br />}</p>
<p>void loop() {</p>
<p>CheckAllEncoders();<br />CheckAllButtons();<br />CheckAllPotentiometers();<br /><br />}</p>
<p>//POTENTIOMETERS PART 3<br />//change the details to match teh details above for each potentiometer you are using<br />void CheckAllPotentiometers(){<br /><br />//potentiometer 1<br />currentOutputLevel = getAverageOutput(potentiometerPin1);<br />zAxis_ = map(currentOutputLevel,0,1023,0,255);<br />Joystick.setZAxis(zAxis_);</p>
<p>//potentiometer 2<br />currentOutputLevel = getAverageOutput(potentiometerPin2);<br />RxAxis_ = map(currentOutputLevel,0,1023,0,255);<br />Joystick.setRxAxis(RxAxis_);</p>
<p><br />}</p>
<p>int getAverageOutput(int pinToRead){<br />index = 0;<br />total = 0; <br /><br />while (index &lt; numReadings){<br />readings = analogRead(pinToRead);<br />total = total + readings;<br />index = index + 1;<br />//delay (1);<br />}<br />return total / numReadings;<br />}</p>
<p><br />void CheckAllButtons(void) {<br />if (buttbx.getKeys())<br />{<br />for (int i=0; i&lt;LIST_MAX; i++) <br />{<br />if ( buttbx.key.stateChanged ) <br />{<br />switch (buttbx.key.kstate) { <br />case PRESSED:<br />case HOLD:<br />Joystick.setButton(buttbx.key.kchar, 1);<br />break;<br />case RELEASED:<br />case IDLE:<br />Joystick.setButton(buttbx.key.kchar, 0);<br />break;<br />}<br />} <br />}<br />}<br />}</p>
<p><br />void rotary_init() {<br />for (int i=0;i&lt;NUMROTARIES;i++) {<br />pinMode(rotaries.pin1, INPUT);<br />pinMode(rotaries.pin2, INPUT);<br />#ifdef ENABLE_PULLUPS<br />digitalWrite(rotaries.pin1, HIGH);<br />digitalWrite(rotaries.pin2, HIGH);<br />#endif<br />}<br />}</p>
<p><br />unsigned char rotary_process(int _i) {<br />//Serial.print("Processing rotary: ");<br />//Serial.println(_i);<br />unsigned char pinstate = (digitalRead(rotaries.pin2) &lt;&lt; 1) | digitalRead(rotaries.pin1);<br />rotaries.state = ttable[rotaries.state &amp; 0xf];<br />return (rotaries.state &amp; 0x30);<br />}</p>
<p>void CheckAllEncoders(void) {<br />Serial.println("Checking rotaries");<br />for (int i=0;i&lt;NUMROTARIES;i++) {<br />unsigned char result = rotary_process(i);<br />if (result == DIR_CCW) {<br />Serial.print("Rotary ");<br />Serial.print(i);<br />Serial.println(" &lt;&lt;&lt; Going CCW");<br />Joystick.setButton(rotaries.ccwchar, 1); delay(50); Joystick.setButton(rotaries.ccwchar, 0);<br />};<br />if (result == DIR_CW) {<br />Serial.print("Rotary ");<br />Serial.print(i);<br />Serial.println(" &gt;&gt;&gt; Going CW");<br />Joystick.setButton(rotaries.cwchar, 1); delay(50); Joystick.setButton(rotaries.cwchar, 0);<br />};<br />}<br />Serial.println("Done checking");<br />}</p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/simhub-support/">Simhub General</category>                        <dc:creator>NewyUK</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3805</guid>
                    </item>
				                    <item>
                        <title>RE: Nextion &amp; Arduino Micro</title>
                        <link>https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3804</link>
                        <pubDate>Sun, 12 Dec 2021 11:28:41 +0000</pubDate>
                        <description><![CDATA[The Man Himself !!!!
I feel honoured. I will give this a go and report back. Thanks so much, for the very prompt response.]]></description>
                        <content:encoded><![CDATA[<p>The Man Himself !!!!</p>
<p>I feel honoured. I will give this a go and report back. Thanks so much, for the very prompt response.</p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/simhub-support/">Simhub General</category>                        <dc:creator>NewyUK</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3804</guid>
                    </item>
				                    <item>
                        <title>RE: Nextion &amp; Arduino Micro</title>
                        <link>https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3803</link>
                        <pubDate>Sun, 12 Dec 2021 09:51:54 +0000</pubDate>
                        <description><![CDATA[Hi ! The underlying basis of the sketch is a simple TTL bridge like this one,minimal code should be enough :
/*
  leo_usb2serial
  Allows to use an Arduino Leonardo as an usb to serial co...]]></description>
                        <content:encoded><![CDATA[<p>Hi ! The underlying basis of the sketch is a simple TTL bridge like this one, <br />https://petervanhoyweghen.wordpress.com/2012/11/08/using-the-leonardo-as-usb-to-serial-converter/<br /><br />This minimal code should be enough :</p>
<pre contenteditable="false">/*
  leo_usb2serial
  Allows to use an Arduino Leonardo as an usb to serial converter.
 */
static long baud = 57600;
static long newBaud = baud;

// this pin will output the DTR signal (as set by the pc)
#define DTR_PIN 13

#define LINESTATE_DTR  1

void lineCodingEvent(long baud, byte databits, byte parity, byte charFormat)
{
  newBaud = baud;
}

void lineStateEvent(unsigned char linestate)
{
  if(linestate &amp; LINESTATE_DTR)
    digitalWrite(DTR_PIN, HIGH);
  else
    digitalWrite(DTR_PIN, LOW);
}

void setup() {
  pinMode(DTR_PIN, OUTPUT);
  digitalWrite(DTR_PIN, LOW);
  Serial.begin(baud);
  Serial1.begin(baud);
}

void loop() {

  // Set the new baud rate
  if(newBaud != baud) {
    baud = newBaud;
    Serial1.end();
    Serial1.begin(baud);
  }

  // copy from virtual serial line to uart and vice versa
  if (Serial.available()) {
    char c = (char)Serial.read();
    Serial1.write(c);
  }
  if (Serial1.available()) {
    char c = (char)Serial1.read();
    Serial.write(c);
  }
}</pre>
<p>If you add things in it, take care not to introduce any "delay" functions, it would make the communication hang, and cause disconnects and/or wrong results on the screen.</p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/simhub-support/">Simhub General</category>                        <dc:creator>Wotever</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3803</guid>
                    </item>
				                    <item>
                        <title>Nextion &amp; Arduino Micro</title>
                        <link>https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3802</link>
                        <pubDate>Sun, 12 Dec 2021 09:40:13 +0000</pubDate>
                        <description><![CDATA[Hi All
This is my first post in the Simhub community but I have been using the software for a while and absolutely love it. I designed and implemented my own dash using a small HDMI screen ...]]></description>
                        <content:encoded><![CDATA[<p>Hi All</p>
<p>This is my first post in the Simhub community but I have been using the software for a while and absolutely love it. I designed and implemented my own dash using a small HDMI screen for my first project and I keep updating it with more and more data. </p>
<p>But recently I have designed and printed my first sim wheel that incorporates a Nextion 3.5" screen attached to an Arduino Micro board. I have some code that uses Keypad.h for my buttons and rotary encoders that works very well. I can upload the NextionMicroBridge.ino that is provided with Simhub to get the screen to work, but when I put the code together the buttons stop working because of the Joystick.h code that is in the Micro Bridge. I am not a coder so don't fully understand how to strip out what I need. </p>
<p>What I'm looking for is a bit of code that links the serial of the Micro to Nextion that works with Simhub without all the LED and JOYSTICK code.</p>
<p>Can anyone please help???</p>]]></content:encoded>
						                            <category domain="https://www.simhubdash.com/community-2/simhub-support/">Simhub General</category>                        <dc:creator>NewyUK</dc:creator>
                        <guid isPermaLink="true">https://www.simhubdash.com/community-2/simhub-support/nextion-arduino-micro-2/#post-3802</guid>
                    </item>
							        </channel>
        </rss>
		