The thread is already quite watertight by itself, some thick grease could do the trick i guess, but i think i’ll used a round flat piece of silicon foam dropped in the cap.
Below is the fusion file:
The trigger and wheel are held with piece of 1/4 inch aluminum tube.
and the slot at the top needs to be filled with transparent silicon.
Body and Body12 need to be acetone glued (if your plastic permits) it’s way better printed in 2 parts.
and this is the code i’m now using:
it’s dirty, but works fine… i got lazy to write something clean to make the leds blink when the mode is confirmed at the end of the setup. And the debugging lines are still in.
Also note, it doesn’t self calibrate yet… so when the hall sensors are glued, they might be in a slightly different position and the code is to account for it.
***** transmitter CODE *****
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver(5000, 0, 1 );
int led1pin = 5;
int led2pin = 6;
int led3pin = 3;
int tpin=0;
int wpin=1;
int vitesse = 0;
int wheel;
int wheelm;
int led1 =0;
int led2 =0;
int led3 =0;
int mode=0;
void setup() {
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
Serial.begin(9600);
if (!driver.init())
Serial.println(“init failed”);
int lx=0;
int x=0;
for (x = 0; x < 5000; x ++) {
lx= lx+1;
if( lx>765 ){
lx=0;
}
led1= constrain(lx,0,255);
led2= constrain(lx-255,0,255);
led3= constrain(lx-510,0,255);
analogWrite(led1pin,led1);
analogWrite(led2pin,led2);
analogWrite(led3pin,led3);
int sensw = analogRead(wpin);
int senst = analogRead(tpin);
if (sensw > 800 ){
mode=1;
analogWrite(led2pin,0);
analogWrite(led3pin,0);
analogWrite(led1pin,255);
delay(500);
analogWrite(led1pin,0);
delay(500);
analogWrite(led1pin,255);
delay(500);
analogWrite(led1pin,0);
delay(500);
break;
}
if (sensw <300 ){
mode=2;
analogWrite(led1pin,0);
analogWrite(led3pin,0);
analogWrite(led2pin,255);
delay(500);
analogWrite(led2pin,0);
delay(500);
analogWrite(led2pin,255);
delay(500);
analogWrite(led2pin,0);
delay(500);
break;
}
if (senst < 300 ){
mode=3;
analogWrite(led1pin,0);
analogWrite(led2pin,0);
analogWrite(led3pin,255);
delay(500);
analogWrite(led3pin,0);
delay(500);
analogWrite(led3pin,255);
delay(500);
analogWrite(led3pin,0);
delay(500);
break;
}
Serial.print(“x”);
Serial.print(x);
Serial.print(“lx”);
Serial.print(lx);
Serial.println();
delay(1);
}
}
void loop() {
int trigger = analogRead(tpin); //480 to 200
if ( mode == 1 || mode == 2 ){
if (trigger<=300){
wheel=analogRead(wpin); // 30 to 1000
if (mode==1){
wheelm=map(wheel,30, 1000, -10, 10);
vitesse = vitesse + wheelm;
}
if (mode==2){
wheelm=map(wheel,30, 1000, 10, -10);
vitesse = vitesse + wheelm;
}
if (vitesse < 5 ) {
vitesse = 5;
}
if (vitesse > 255 ) {
vitesse = 255;
}
}
else{
vitesse = 0;
}
}
if(mode==3){
vitesse = constrain(map(trigger, 480, 200, 0, 255), 0, 255);
}
led1= constrain(vitesse * 3 ,0,255);
led2= constrain(vitesse * 3-255,0,255);
led3= constrain(vitesse * 3-510,0,255);
analogWrite(led1pin,led1);
analogWrite(led2pin,led2);
analogWrite(led3pin,led3);
uint8_t values[1];
values[0]=(uint8_t) vitesse;
driver.send(values, 1);
driver.waitPacketSent();
delay(2);
Serial.print(“trigger:”);
Serial.print(trigger);
Serial.print(“wheel”);
Serial.print(wheel);
Serial.print(“wheelm”);
Serial.print(wheelm);
Serial.print(“vitesse”);
Serial.print(vitesse);
Serial.print(“mode”);
Serial.print(mode);
Serial.println();
}
***** RECEIVER CODE *****
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
#include <SoftwareServo.h>
RH_ASK driver(5000, 0, 1 );
SoftwareServo esc;
int SERVO_LOW = 0;
int SERVO_HIGH = 180;
int c1,c2,c3;
int v1=0;
unsigned long lastM;
unsigned long currentT;
int ledPin=4;
void setup() {
pinMode(ledPin,OUTPUT);
esc.attach(3);
Serial.begin(9600);
if (!driver.init())
Serial.println(“init failed”);
}
void loop() {
uint8_t buf[4];
uint8_t buflen = sizeof(buf);
esc.refresh();
if (driver.recv(buf, &buflen))
{
c1 = buf[0];
lastM = millis();
v1 = map(c1, 0, 255, SERVO_LOW, SERVO_HIGH);
digitalWrite(ledPin,HIGH);
}
esc.write(v1);
esc.refresh();
delay(50);
currentT = millis();
if((unsigned long)(currentT-lastM) > 1000 )
{
esc.write(0);
digitalWrite(ledPin,LOW);
esc.refresh();
v1=0;
}
Serial.print(" v1:");
Serial.print(v1);
Serial.print(" currentT:");
Serial.print(currentT);
Serial.print(" lastM:");
Serial.println(lastM);
Serial.print(" c1:");
Serial.println(c1);
}