is it possible to c...
 
Notifications
Clear all

is it possible to control i/o pins on arduino with simhub led functions?

4 Posts
4 Users
1 Likes
2,003 Views
(@blackghostd5)
New Member
Joined: 3 years ago
Posts: 4
Topic starter  

I have read a question here before, that feature is disabled, because of controller overcurrent damages, when people would hook up a buttload of leds to their arduinos, but is there a way to controll gpio high or low? I have a gauge cluster from a car, and i want to make the leds on it functional like handbrake, abs, traction controll etc... i would use n channel mosfets to pull their gnd low with an arduino pin, so not a lot of current would flow, and there would be like 5 lights, so i dont think it would damage the chip. maybe an advanced page in hw configuration that is accessible with a checkbox that i know i can screw up my arduino and simhub isn't responsible for it, the usual things. I would really appreciate

any help regarding this project, and happy holidays everyone!


   
Quote
(@samuel)
New Member
Joined: 3 years ago
Posts: 1
 
hello, i have the same problem, i want to turn on dashboard lights like handbrake, abs, traction control, but i don't know how to do it

   
ReplyQuote
 sgeg
(@sgeg)
Trusted Member
Joined: 3 years ago
Posts: 51
 

hello,

first i must to say i am totally newbie in programing but i found a sketch where the guy use relay for this fonction on a e46 cluster in SHcustomprotocol

see attach the code for the hand brake i found, i didn't try but can be a good start

 

#ifndef __SHCUSTOMPROTOCOL_H__
#define __SHCUSTOMPROTOCOL_H__

#include <Arduino.h>



// Set Relay Pins

int pinParkingpbrake = 40;

// SimHub Variables
  
String parkingbreak;

class SHCustomProtocol {
private:

public:

	/*
	CUSTOM PROTOCOL CLASS
	SEE  https://github.com/zegreatclan/SimHub/wiki/Custom-Arduino-hardware-support 

	GENERAL RULES :
		- ALWAYS BACKUP THIS FILE, reinstalling/updating SimHub would overwrite it with the default version.
		- Read data AS FAST AS POSSIBLE in the read function
		- NEVER block the arduino (using delay for instance)
		- Make sure the data read in "read()" function READS ALL THE DATA from the serial port matching the custom protocol definition
		- Idle function is called hundreds of times per second, never use it for slow code, arduino performances would fall
		- If you use library suspending interrupts make sure to use it only in the "read" function when ALL data has been read from the serial port.
			It is the only interrupt safe place

	COMMON FUNCTIONS :
		- FlowSerialReadStringUntil('\n')
			Read the incoming data up to the end (\n) won't be included
		- FlowSerialReadStringUntil(';')
			Read the incoming data up to the separator (;) separator won't be included
		- FlowSerialDebugPrintLn(string)
			Send a debug message to simhub which will display in the log panel and log file (only use it when debugging, it would slow down arduino in run conditions)

	*/

	// Called when starting the arduino (setup method in main sketch)
	void setup() {
// Output Definition

  pinMode(pinParkingpbrake, OUTPUT);

// // Output Set

  digitalWrite(pinParkingpbrake, HIGH);


	// Called when new data is coming from computer
	void read() {
		// EXAMPLE 1 - read the whole message and sent it back to simhub as debug message
		// Protocol formula can be set in simhub to anything, it will just echo it
		// -------------------------------------------------------
  
      parkingbreak = FlowSerialReadStringUntil(';');
      
	
		/*
		// -------------------------------------------------------
		// EXAMPLE 2 - reads speed and gear from the message
		// Protocol formula must be set in simhub to
		// format([DataCorePlugin.GameData.NewData.SpeedKmh],'0') + ';' + isnull([DataCorePlugin.GameData.NewData.Gear],'N')
		// -------------------------------------------------------

	
		*/
	}

	// Called once per arduino loop, timing can't be predicted, 
	// but it's called between each command sent to the arduino
 
	void loop() {
  

// Parkingbrake
if(parkingbreak.equalsIgnoreCase("True")) {
  digitalWrite(pinParkingpbrake, LOW);  
}
else {
  digitalWrite(pinParkingpbrake, HIGH); 
}

 


   
CelicaT230 reacted
ReplyQuote
(@issacsim)
New Member
Joined: 5 months ago
Posts: 2
 

Did anyone ever figure out how to do this?

Looking to do something similar...


   
ReplyQuote
Share: