What to write in product code for making alert sound in buzzer when price of bitcoin exceeds the selling price

This is the main code which first let the user choose their favorable currency then asks them for their selling price. Then it searches the web for current bitcoin market value according to the chosen currency then it prints the current market value and selling price on screen then it checks the following conditions :
(i) if current market price bitcoin is less than of selling price
(ii) if current market price bitcoin is greater than of selling price
then it gives corresponding message alert in both cases which triggers both led and buzzer respectively.

import conf      
import time
import json 
import requests
from boltiot import Bolt,Sms


print("Select any one of the following currency input\nINR\nUSD\nJPY\nEUR")
currency=input("Enter the above Currency from which you have to invest in:")
sell_price=float(input("Enter Your Selling Price:"))

def price_check():
    return current_price

while True:
    print("Market price of Bitcoin is:",market_price)
    print("Selling Price is:",sell_price)
         if market_price < sell_price:      
             response1=sms.send_sms("The Bitcoins are at price ={} You can Invest now if you want".format(current_bitcoin_value))
             print("Status of Sms at Twilo:"+str(response1.status))
          elif market_price > sell_price:
              bolt.digitalWrite("1","HIGH")#BUZZER gets "ON
             response1=sms.send_sms("The Bitcoins are at price ={} You need to be cautious".format(current_bitcoin_value))
             print("Status of Sms at Twilo:"+str(response1.status))
    except Exception as e:
        print("An error occured\n")
    bolt.digitalWrite("0","LOW")#led gets off
    bolt.digitalWrite("1","LOW")#buzzer gets off

Try this and do let us know if it helps you.

this error is coming when i run that code

i wrote the conf information like this
i connect the buzzer and nake a product on bolt cloud and then in the configuration i didnt write any javascript code and when i am running it ,i think the output is directly going on exception bloack

try block is not executing

Noted your query, give me some to check into this.

i got the issue and i fixed it ,the error was in the code twilio response variable was wrong

in place of current bitcoin value variable i changed it to market price

1 Like