This week's giveaway is in the Java in General forum.
We're giving away four copies of Java Challengers and have Rafael del Nero on-line!
See this thread for details.
Win a copy of Java Challengers this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Smart light

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I am working on a Smart Light project, I managed to build a switch to turn a light on or off.
I have created a slider in Javascript, where I can fill in the lux (luminous intensity), but now I have to write some Java code as well.
For example when the lux will is 400 (nice sunny day) the lights will turn off.
When it is getting dark, the light will turn on.

I am a beginner, and I cannot find any example code, I am so tired of Googling so maybe someone can help me a bit t get started at least, or tell me where I can find examples.

Thank you so much! Danielle  
 
Saloon Keeper
Posts: 6929
164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Please tell us a bit more about the type of project. You mentioned JavaScript - is this part of a web site? But then you mentioned Java, so it can't run entirely in the browser. TellTheDetails
 
Danielle Mertens
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry ...

Actually I am building a website in Springboot, I am working with Javascript, React, CSS and HTML so it will look nice on the front end. I can work with this, so for this part I am fine.

The logic behind the app however, should be coded in Java, and for this part I could use some help.

I will give you some examples what I would like to program:

SMART LIGHTING IDEAS
1. One button press turns on all lighting for a given room or floor, not just one light.
2. Double-tap the same button to turn everything (lighting, electronics, devices, etc.) in the room off.
3. Lights flash in your garage when someone rings the doorbell.
4. When then garage door opens after dark, the outdoor lights leading up to your door and just inside the house automatically turn on.
5. Motion sensors in critical areas can signal the automation system to switch off lights when a room has been vacant for some time.
6. Landscape lighting can turn on automatically at sunset and off again at sunrise.
7. A “Bedtime” scene can set bedside lamps at a level just low enough for comfortable reading.
8. With the touch of an “All Off” button, all of the lights in your entire home turn off.
9. Midnight snack – just enough light to make your way to the refrigerator and back without disturbing family members.
10. Motion sensing – At night, when motion is sensed, ramp lights to 15% (just enough light to see, not to be blinded).

I hope I am more clear now.
Danielle
 
Tim Moores
Saloon Keeper
Posts: 6929
164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that is clear. What do you have so far, and where are you stuck making progress?
 
Danielle Mertens
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created some working code, where I can see the status of the lamp. Where is the lamp, is it turned on or off.
What is the location of the lamp etc.

I want to create a sensor (in Java code) that can check the lux (how much light we have outside) and the sensor well based on the turn on the light, turn off the light, dim the light or make it brighter.
I just don't know where to start .

https://en.wikipedia.org/wiki/Lux#Illuminance

Danielle

 
Marshal
Posts: 72657
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch (again)

Which part of the project do you think should be done first? What about measuring ambient light levels. Would the mean indoors or outdoors only?
 
Danielle Mertens
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's keep it simple, I will only use indoor lights. Actually explaining this to you, gave me some inspiration how to start!
I will wirte some code and share it with you tomorrow, because is is getting a bit late here now, and I have online classes tomorrow morning...
Is that an idea?
Danielle
 
Campbell Ritchie
Marshal
Posts: 72657
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Danielle Mertens wrote:Let's keep it simple, . . .

You will find programming much easier if you start with everything kept simple
I was thinking about sensors testing the brightness of natural light, hence outdoors, but you can probably do any parts of the exercise in any order and have it work nicely.

explaining this to you, gave me some inspiration . . .

Look up “rubber duck programming”

I will wirte some code and share it with you tomorrow, because is is getting a bit late here now, and I have online classes tomorrow morning...
Is that an idea?
Danielle

Yes, but make sure you decide what you are going to program before you write any code.
 
Danielle Mertens
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I was thinking about sensors testing the brightness of natural light, hence outdoors, but you can probably do any parts of the exercise in any order and have it work nicely.



I am back, I thought the same thing. So i made (tried) to change the light based on lux.
Just working on it, little by little.

https://repl.it/@DanielleMertens/LightSensor

Danielle
 
Danielle Mertens
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Look up “rubber duck programming”

That is amazing I need a ducky now for sure!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic