Forum Replies Created
-
AuthorPosts
-
January 1, 2015 at 17:51 in reply to: Conversion of ReadSensorColorEx(IN_1,colorval,raw,norm,scaled) C function in F# #5169
Tcm0ParticipantAre you sure that you want to use F# and not C#?
Tcm0ParticipantThank you.
It’s not really possible to detect the color “orange” with the sensor. You can still use the reflected light mode.
Theoretically you could use the “RGB Mode” of the EV3s color sensor but that is not supported by MonoBrick.
Tcm0ParticipantGreat 🙂
Could you please give me tips on how to make the tutorial better?
Tcm0Participant“I have tried leJOS and it is hosted in the ev3 brick which can be controlled by any device that is connected in the same network (is thr any solution for different network?).”
You can open the port to access the website (probably 8080 redirect to 80). Then everything can access to the server from the internet. But you have to get the online IP somehow.“Is there any way like hosting an ASP.net online website somewhere outside rather then on the EV3, so i can still able to control ev3 during my oversea trip.”
You can run a webserver on a computer which can access the EV3 through the MonoBrick communication library.
Tcm0ParticipantI think that it’s theoretically possible to open a hotspot on your phone. But I don’t know how good that works.
Tcm0ParticipantMonoBrick doesn’t support bluetooth yet.
You can try to use Wifi instead of bluetooth.
Tcm0ParticipantYes, the template is working and mentioned in the tutorial. But it’s not very comfortable because you can’t return to the main menu when you started an app.
Tcm0ParticipantTho you can still read it with “ReadRaw ()” and “Read ()”. It just won’t return colors but light intensity in percent.
Tcm0Participant“Try to read 8 bytes instead of four. I found that some sensors only supports read 8 bytes at a time. If this does not work try to read a single byte.” (Anders Søborg)
Tcm0ParticipantCould you please try the following code?
using System; using MonoBrickFirmware.Sensors; namespace MonoBrickHelloWorld { public class MindsensorsAbsoluteIMU : I2CSensor { public MindsensorsAbsoluteIMU (SensorPort Port) : base (Port, (byte)0x22, I2CMode.LowSpeed) { base.Initialise (); } public void ChangeAccelerometerSensitivity (string Sensitivity) { byte[] BytesToWrite = {(byte)0}; if (Sensitivity == "2G" || Sensitivity == "2g") BytesToWrite[0] = (byte) 0x31; else if (Sensitivity == "4G" || Sensitivity == "4g") BytesToWrite[0] = (byte) 0x32; else if (Sensitivity == "8G" || Sensitivity == "8g") BytesToWrite[0] = (byte) 0x33; else if (Sensitivity == "16G" || Sensitivity == "16g") BytesToWrite[0] = (byte) 0x34; else throw new ArgumentException(); base.WriteRegister((byte)0x22, BytesToWrite); return; } public byte[] ReadX () { return(base.ReadRegister ((byte)0x42, 8)); } public byte[] ReadY () { return(base.ReadRegister ((byte)0x43, 8)); } public byte[] ReadZ () { return(base.ReadRegister ((byte)0x44, 8)); } public override string ReadAsString() { return("X: " + Convert.ToString(base.ReadRegister(0x42)) + " Y: " + Convert.ToString(base.ReadRegister(0x43)) + " Z: " + Convert.ToString(base.ReadRegister(0x44))); } public override void SelectNextMode() { return; } public override void SelectPreviousMode() { return; } public override string GetSensorName() { return (Convert.ToString (base.ReadRegister ((byte)0x10, (byte)0x07))); } public override int NumberOfModes() { return 1; } public override string SelectedMode() { return ("Mode 1"); } } }
using System; using MonoBrickFirmware; using MonoBrickFirmware.Display; using MonoBrickFirmware.UserInput; using System.Threading; using MonoBrickFirmware.Sensors; namespace MonoBrickHelloWorld { class MainClass { public static void Main (string[] args) { EventWaitHandle stopped = new ManualResetEvent (false); MindsensorsAbsoluteIMU NewSensor = new MindsensorsAbsoluteIMU (SensorPort.In1); ButtonEvents buts = new ButtonEvents (); buts.EscapePressed += () => { stopped.Set (); }; buts.EnterPressed += () => { LcdConsole.WriteLine(NewSensor.ReadAsString()); }; LcdConsole.WriteLine ("Hello World"); stopped.WaitOne (); } } }
(Why can’t we attach .cs files?)
- This reply was modified 10 years ago by Tcm0.
Tcm0ParticipantIt may use the 9V I2C Sensor mode.
Tcm0ParticipantYour sensor is an I2C sensor. You can find information about the usage of an I2C sensor at https://github.com/Larsjep/monoev3/blob/release/MonoBrickFirmware/Sensors/HTColorSensor.cs. Other information about the adresses to be read etc. can be found in the official sourcecode for the NXC library: http://www.mindsensors.com/index.php?module=documents&JAS_DocumentManager_op=viewDocument&JAS_Document_id=198 (IMU-lib.nxc). The adress of the I2C sensor appears to be 0x22 as you can find in the demo (IMU-demo.nxc).
Tcm0ParticipantI think that you can write a message to the EV3’s bluetooth message box by using http://www.monobrick.dk/MonoBrickDocumentation/class_mono_brick_1_1_e_v3_1_1_mailbox.html.
Tcm0ParticipantThis probably helps you too: http://www.monobrick.dk/MonoBrickDocumentation/class_mono_brick_1_1_n_x_t_1_1_i2_c_sensor.html
Tcm0ParticipantAre you sure that the PCF8574AP is no 9V sensor? In that case you would have to use another mode.
-
AuthorPosts
Follow