15. Jarvis Main Function | Home Automation using Arduino, Smart Phone App and Jarvis [Must Watch]
So i will call the main function here and image to store the take one functions value in a separate variable. First, i will call the query variable and i will take it equal to take command now. The important thing here is that sometimes the take mod function understands our command as all lowercase letters, but sometimes it understand it as the first letter is capital and all those remaining letters are small, so the problem is that there is no way we can predict what It will understand the command, as so, to get rid of this error, we will call another function here, which is a prebuilt function in python, dot lower what this function does. Is it converts all of the letters in the demand function to lower case now before moving forward to our? If else conditions? I will move this line right here to our forever loop, so i will go here and here i will define our for our loop. While true and i will add the indentation here, so our query will be in a forever loop as we want it to keep on recognizing the commands as long as we want it to so in here, under the query variable, i will define the fs condition. So first condition will be, if date in query, so what this means that, if the date belongs to the query, not if query is equal to the date, so there is a big difference here.
We could also say if date is equal to query or, if query is equal to date, but this will restrict us to say exact date. So what this line means is that, if date belongs to the query like it does not matter if they are equal, like they have the same words, the only thing that matters is if the word date is in the query like we can also say jarvis. Tell me the date or what is the date. They are both correct as long as the word date is in it. So this gives us a little bit more. Flexibility as compared to query is equal to date statement so in here i will call the date function that we created earlier now for the time command. I will say as if now in python else, if is written as alif, so i will say lf time in query now. In this scenario i wanted to call the time function that we created. So i will say time underscore parenthesis, so i will save it and we can simply run this command again now you can see that it is asking me for a command as it is printing listening. So i will say: jarvis tell me the date. 26. 8. 2021. Now you can see that it did not make any difference, as the word did was in the command. So the next thing i will say is jarvis tell me the time. The current time is 58 minutes and 24 seconds.
The current time is 12 hours, 58 minutes and 29 seconds, so it is working correctly.
Recent Comments