Liberty BASIC Community Forum
« Arduino controlled by Screen lighting in Liberty »

Welcome Guest. Please Login or Register.
Jul 25th, 2017, 11:39am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Arduino controlled by Screen lighting in Liberty  (Read 352 times)
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Arduino controlled by Screen lighting in Liberty
« Thread started on: Jan 25th, 2016, 10:24pm »

VIDEO DEMO HERE:
https://youtu.be/KbbxJSu4yO0


As this program is improved I will also improve the hardware interface..

It was just taped together to prove that this can be done effectively..
I made the Liberty Basic Program and the C++ code for the IDE to make the interface controls..

I have tested this with an LED and it has more range, but this graphics screen example is soo cool..

This type of construction is useful when you have a ATMEGA or Attiny that is not attached to an Arduino..

Here is the video and I will update this post when the 13 pins are accessable in a more user friendly interface. I may just have it on a separate monitor so the main screen is not being blocked.

With advancement this should be an effective interface.. AND eventually could program the Atmega with modification in the code. I am studying the way the Atmega stores information during power down..

In my basic program you would be limited to ranges of around 5- 10 (every ten counts you can assign to a pin) out of a range of 255, but that can triple if you get the non reduced light values..

To gain data from the Arduino the process would only need to be reversed... Preferably with LEDs or IR sensor (so that external light doesn't interfere.


Here is the Liberty Basic code... I will post the Arduino IDE interface code only once when its ready to use.

This program is not properly organized as you will notice pin9 call is used to control on/off switches for pin 9 and 10 .
I will fix that when I get the final product ready. (at least for the one way communication)
The BASIC program :( From the Demo)
Code:
call screen ' I made this for a generic screen call
[loop]
call pin9 "on"
for x = 1 to 1000000
scan
next x
call pin9 "off"
for x = 1 to 1000000
scan
next x
goto [loop]
wait
[quit]
#1 "discard"
close #1
end

sub screen
   nomainwin
   open "Another way of doing graphics !!" for graphics_nsb_fs as #1
   print #1, "Down trapclose [quit]"

    print #1, "fill black ; home ; down ; north"
end sub
' generic circle   syntax -  circle horizontal, vertical, size, color$
sub circle x, y, size, color$
   print #1," place  "; x;" ";y
   print #1," color "; color$
   print #1," circle "; size
end sub

sub pin9 onoff$
if onoff$="on" then #1 "down;backcolor 250 250 250;fill 250 250 250"
if onoff$="off" then #1 "down;backcolor 100 100 100;fill 100 100 100"

end sub 




« Last Edit: Feb 6th, 2016, 11:23pm by michael » User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5366
xx Re: Arduino controlled by Screen lighting in Liber
« Reply #1 on: Jan 26th, 2016, 04:48am »

Cool, a long time ago the BBC used to broadcast computer programs that way. You stuck a sensor on the tv and it downloaded the program as you watched.
User IP Logged

tenochtitlanuk
Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1159
xx Re: Arduino controlled by Screen lighting in Liber
« Reply #2 on: Jan 26th, 2016, 04:50am »

Reminds me of, over 35 years ago, using photosensors in front of the screen of early micros like the PET to get an (isolated) output signal.
Incidentally, for/next loops eat processer time and take different times on different machines. Better to use
Code:
CallDLL #kernel32, "Sleep", m As ulong, Sleep As void 

I love this kind of tinkering with interacting machines.
User IP Logged

michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: Arduino controlled by Screen lighting in Liber
« Reply #3 on: Jan 26th, 2016, 09:39am »

IF we accomplish the following task, a new world will be opened to computer/chip communication/data storage.

Here is the sensor I used :

https://www.bc-robotics.com/shop/photocell/

Perhaps you can help me complete the link..

I don't want to use the Arduino as a slave to do this.. I want to do it with a USB.

I already know how to use LEDs to communicate data, and they have more range in this project..

All I need on the USB side is a photo cell to receive the data back from the Arduino. The photo cell would allow the computer to receive data from a variable controlled LED.

I am currently searching for a solution online, but so far no one is trying to do this.

The Arduino would then only be needed to set up the chips.

Benefits of this-

1 ) in future advanced versions I could set it up to send/ receive data, say from a Arduino or ESP8266 to update a screen you see on the unit without establishing a wifi connection ..

2) Real time monitor of your running program.. The ATMEGA , Attiny and Esp8266 could communicate directly with Liberty basic with no wires , and NO ARDUINO.

3) Smooth operation with less complication and small simple coding for the BASIC programmer.

4) Instant update of motor controls and stepper motors without using the Arduino

I am currently working on an IR sensor Reciever solution also ( but I dont want to use the IR remote library.. I will redefine the way the IR sensor and reciever will transmit data.

( this will eliminate the problems with external light sources)
( but then I would have to work with time measures..)

BUT there is this solution: The basic IR alternative with similar properties to the photo sensor:
http://www.bc-robotics.com/shop/ltr-302-emitter/

SUPER SAFE and all with liberty basic..
« Last Edit: Jan 26th, 2016, 11:18am by michael » User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
michael
Team Liberty BASIC


member is offline

Avatar




PM


Posts: 111
xx Re: Arduino controlled by Screen lighting in Liber
« Reply #4 on: Feb 5th, 2016, 11:02pm »

This is part of the Liberty Basic project.. I will be replacing the communication sensors with

IR- Emitters
IR Detectors
on USB com side and on Chip side

Some of this code comes from public domain.

Here is the C code for the interface for this control mechanism under Liberty Basic..

I am currently having issues with my COM port connection and this tool is becoming more important now than ever.

I Don't disconnect my Arduino for fear it may act up.. so I must work carefully..
I think it is to do with current software/ hardware changes and the fact that I was using many Arduinos to separate my programming platforms..
There are 2 permanent connections on 2 computers and One has this project.. Once this project is completed and the solution to sending info back to the computer is solved, then there will be no need for "Hand shaking" and I will also find a solution to actually programming the controller with the flash memory built in.. So These chips will be able to be Arduino free and Wirelessly Liberty controlled.

This example code is part of the public domain
*/
Code:
 

const int greenLEDPin = 9;    // LED connected to digital pin 9
const int redLEDPin = 10;     // LED connected to digital pin 10
const int blueLEDPin = 11;    // LED connected to digital pin 11

const int redSensorPin = A0;  // pin with the photoresistor with the red gel
const int greenSensorPin = A1;   // pin with the photoresistor with the green gel
const int blueSensorPin = A2;   // pin with the photoresistor with the blue gel

int redValue = 0; // value to write to the red LED
int greenValue = 0; // value to write to the green LED
int blueValue = 0; // value to write to the blue LED

int redSensorValue = 0; // variable to hold the value from the red sensor
int greenSensorValue = 0; // variable to hold the value from the green sensor
int blueSensorValue = 0; // variable to hold the value from the blue sensor

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);

  // set the digital pins as outputs
  pinMode(greenLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(blueLEDPin, OUTPUT);
}

void loop() {
  // Read the sensors first:

  // read the value from the red-filtered photoresistor:
  redSensorValue = analogRead(redSensorPin);
  // give the ADC a moment to settle
  delay(5);
  // read the value from the green-filtered photoresistor:
  greenSensorValue = analogRead(greenSensorPin);
  // give the ADC a moment to settle
  delay(5);
  // read the value from the blue-filtered photoresistor:
  blueSensorValue = analogRead(blueSensorPin);

  // raw sensor values print out the values to the serial monitor
  

  /*
  In order to use the values from the sensor for the LED,
  you need to do some math. The ADC provides a 10-bit number,
  but analogWrite() uses 8 bits. You'll want to divide your
  sensor readings by 4 to keep them in range of the output.
  */
  redValue = redSensorValue / 4;
  greenValue = greenSensorValue / 4;
  blueValue = blueSensorValue / 4;

  //  print out the mapped values
  Serial.print("Mapped sensor Values \t red: ");
  Serial.print(redValue);
  Serial.print("\t green: ");
  Serial.print(greenValue);
  Serial.print("\t Blue: ");
  Serial.println(blueValue);

  /*
  Now that you have a usable value, it's time to PWM the LED.
  */
  if (redValue < 75) {analogWrite(redLEDPin, redValue);}
  if (redValue > 80) {analogWrite(redLEDPin, LOW);}
  analogWrite(greenLEDPin, greenValue);
  if (greenValue < 100) {analogWrite(greenLEDPin, LOW);}
  if (greenValue > 100) {analogWrite(greenLEDPin, greenValue);}
  analogWrite(blueLEDPin, blueValue);
}
 
« Last Edit: Feb 5th, 2016, 11:03pm by michael » User IP Logged

I like making program generators and reinventing the wheel.. I never make mistakes.. Not ever.. (lie)
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5366
xx Re: Arduino controlled by Screen lighting in Liber
« Reply #5 on: Feb 6th, 2016, 02:25am »

Problems as you describe are most always to do with cleaning the power supply to the Arduino. If you have motors or steppers or servos they must always be run by s separate power supply. They can share a common ground but anything that consumes power should have its own supply. It might be your LEDs if they are powerful they will consume quite a few watts/amps.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls